each while
for filters> each while {flags} (closure)
closure
: the closure to runinput | output |
---|---|
list<any> | list<any> |
table | list<any> |
Produces a list of each element before the 3, doubled
> [12321] |each while {|e| if$e<3 { $e*2 } }
╭───┬───╮
│0│2│
│1│4│
╰───┴───╯
Output elements until reaching 'stop'
> [12stop34] |each while {|e| if$e!='stop' { $"Output: ($e)" } }
╭───┬───────────╮
│0│Output:1│
│1│Output:2│
╰───┴───────────╯
Iterate over each element, printing the matching value and its index
> [123] |enumerate|each while {|e| if$e.item<2 { $"value ($e.item) at ($e.index)!"} }
╭───┬───────────────╮
│0│value1at0!│
╰───┴───────────────╯
Tips: Command each while
was not included in the official binaries by default, you have to build it with --features=extra
flag
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/each_while.html