insert
for filters> insert {flags} (field) (new value)
field
: the name of the column to insertnew value
: the new value to give the cell(s)input | output |
---|---|
list<any> | list<any> |
record | record |
table | table |
Insert a new entry into a single record
> {'name':'nu', 'stars':5} |insertalias'Nushell'
╭───────┬─────────╮
│name│nu│
│stars│5│
│alias│Nushell│
╰───────┴─────────╯
Insert a new column into a table, populating all rows
> [[project, lang]; ['Nushell', 'Rust']] |inserttype'shell'
╭───┬─────────┬──────┬───────╮
│# │ project │ lang │ type │
├───┼─────────┼──────┼───────┤
│0│Nushell│Rust│shell│
╰───┴─────────┴──────┴───────╯
Insert a column with values equal to their row index, plus the value of 'foo' in each row
> [[foo]; [7] [8] [9]] |enumerate|insertbar {|e| $e.item.foo+$e.index } |flatten
╭───┬─────┬─────╮
│# │ foo │ bar │
├───┼─────┼─────┤
│0│7│7│
│1│8│9│
│2│9│11│
╰───┴─────┴─────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/insert.html