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 for filters

Take only the first n elements of a list, or the first n bytes of a binary value.

Signature

> take {flags} (n)

Parameters

  • n: Starting from the front, the number of elements to return.

Input/output types:

inputoutput
tabletable
list<any>list<any>
binarybinary
rangelist<number>

Examples

Return the first item of a list/table

> [1 2 3] | take 1
╭───┬───╮
│ 0 │ 1 │
╰───┴───╯

Return the first 2 items of a list/table

> [1 2 3] | take 2
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
╰───┴───╯

Return the first two rows of a table

> [[editions]; [2015] [2018] [2021]] | take 2
╭───┬──────────╮
│ # │ editions │
├───┼──────────┤
│ 0 │     2015 │
│ 1 │     2018 │
╰───┴──────────╯

Return the first 2 bytes of a binary value

> 0x[01 23 45] | take 2
Length: 2 (0x2) bytes | printable whitespace ascii_other non_ascii
00000000:   01 23                                                •#

Return the first 3 elements of a range

> 1..10 | take 3
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
╰───┴───╯

Subcommands:

namedescriptiontype
take untilTake elements of the input until a predicate is true.built-in
take whileTake elements of the input while a predicate is true.built-in