Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

take until for filters

Take elements of the input until a predicate is true.

Signature

> take until {flags} (predicate)

Flags

  • --include, -i {int}: Include extra items after the stream would otherwise have stopped. 0 is a no-op.

Parameters

  • predicate: The predicate that element(s) must not match.

Input/output types:

inputoutput
tabletable
list<any>list<any>

Examples

Take until the element is positive.

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

Take until the element is positive using stored condition.

> let cond = {|x| $x > 0 }; [-1 -2 9 1] | 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 │
╰───┴────╯

Take until the first item with an uppercase name including that item.

> [[name value]; [b, 2], [c, 3], [A, 1], [D, 4]] | take until -i 1 {|x| $x.name like '[A-Z]' }
╭───┬──────┬───────╮
│ # │ name │ value │
├───┼──────┼───────┤
│ 0 │ b    │     2 │
│ 1 │ c    │     3 │
│ 2 │ A    │     1 │
╰───┴──────┴───────╯