W3cubDocs

/Nushell

take until for filters

Take elements of the input until a predicate is true.

Signature

> take until {flags} (predicate)

Parameters

  • predicate: the predicate that element(s) must not match

Input/output types:

input output
list<any> list<any>
table table

Examples

Take until the element is positive

> [-1-291] |take until {|x| $x>0 }
╭───┬────╮
0-1
1-2
╰───┴────╯

Take until the element is positive using stored condition

>letcond= {|x| $x>0 }; [-1-291] |take until$cond
╭───┬────╮
0-1
1-2
╰───┴────╯

Take until the field value is positive

> [{a:-1} {a:-2} {a:9} {a:1}] |take until {|x| $x.a>0 }
╭───┬────╮
# │ a  │
├───┼────┤
0-1
1-2
╰───┴────╯

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