W3cubDocs

/Nushell

select for filters

Select only these columns or rows from the input. Opposite of `reject`.

Signature

> select {flags} ...rest

Flags

  • --ignore-errors, -i: ignore missing data (make all cell path members optional)

Parameters

  • ...rest: the columns to select from the table

Input/output types:

input output
list<any> any
record record
table table

Examples

Select a column in a table

> [{a:ab:b}] |selecta
╭───┬───╮
# │ a │
├───┼───┤
0a
╰───┴───╯

Select a field in a record

> {a:ab:b} |selecta
╭───┬───╮
aa
╰───┴───╯

Select just the name column

>ls|selectname

Select the first four rows (this is the same as first 4)

>ls|select0123

Select columns by a provided list of columns

>letcols= [nametype];[[nametypesize]; [Cargo.tomltoml1kb] [Cargo.locktoml2kb]] |select$cols

Select rows by a provided list of rows

>letrows= [02];[[nametypesize]; [Cargo.tomltoml1kb] [Cargo.locktoml2kb] [file.jsonjson3kb]] |select$rows

Notes

This differs from get in that, rather than accessing the given value in the data structure, it removes all non-selected values from the structure. Hence, using select on a table will produce a table, a list will produce a list, and a record will produce a record.

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