W3cubDocs

/Nushell

path basename for path

Get the final component of a path.

Signature

> path basename {flags}

Flags

  • --replace, -r {string}: Return original path with basename replaced by this string

Input/output types:

input output
list<string> list<string>
string string

Examples

Get basename of a path

>'/home/joe/test.txt'|path basename
test.txt

Get basename of a list of paths

> [ /home/joe, /home/doe ] |path basename
╭───┬─────╮
0joe
1doe
╰───┴─────╯

Replace basename of a path

>'/home/joe/test.txt'|path basename-r'spam.png'
/home/joe/spam.png

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/path_basename.html