path split

For path.

Split a path into a list based on the system's path separator.

Command Type

built-in

Signature

> path split {flags}

Input/output types:

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

Examples

Split a path into parts.

> '/home/viking/spam.txt' | path split
╭───┬──────────╮
│ 0 │ /        │
│ 1 │ home     │
│ 2 │ viking   │
│ 3 │ spam.txt │
╰───┴──────────╯

Split paths in list into parts.

> [ /home/viking/spam.txt /home/viking/eggs.txt ] | path split
╭───┬──────────────────╮
│ 0 │ ╭───┬──────────╮ │
│   │ │ 0 │ /        │ │
│   │ │ 1 │ home     │ │
│   │ │ 2 │ viking   │ │
│   │ │ 3 │ spam.txt │ │
│   │ ╰───┴──────────╯ │
│ 1 │ ╭───┬──────────╮ │
│   │ │ 0 │ /        │ │
│   │ │ 1 │ home     │ │
│   │ │ 2 │ viking   │ │
│   │ │ 3 │ eggs.txt │ │
│   │ ╰───┴──────────╯ │
╰───┴──────────────────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.