path parse
for path> path parse {flags}
--extension, -e {string}
: Manually supply the extension (without the dot)input | output |
---|---|
list<string> | table |
string | record |
Parse a path
>'/home/viking/spam.txt'|path parse
╭───────────┬──────────────╮
│parent│/home/viking│
│stem│spam│
│extension│txt│
╰───────────┴──────────────╯
Replace a complex extension
>'/home/viking/spam.tar.gz'|path parse-etar.gz|upsertextension { 'txt' }
Ignore the extension
>'/etc/conf.d'|path parse-e''
╭───────────┬────────╮
│parent│/etc│
│stem│conf.d│
│extension││
╰───────────┴────────╯
Parse all paths in a list
> [ /home/viking.d/home/spam.txt ] |path parse
╭───┬────────┬────────┬───────────╮
│# │ parent │ stem │ extension │
├───┼────────┼────────┼───────────┤
│0│/home│viking│d│
│1│/home│spam│txt│
╰───┴────────┴────────┴───────────╯
Each path is split into a table with 'parent', 'stem' and 'extension' fields. On Windows, an extra 'prefix' column is added.
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/path_parse.html