W3cubDocs

/Nushell

prepend for filters

Prepend any number of rows to a table.

Signature

> prepend {flags} (row)

Parameters

  • row: the row, list, or table to prepend

Input/output types:

input output
any list<any>

Examples

prepend a list to an item

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

Prepend a list of strings to a string

>"a"|prepend ["b"]
╭───┬───╮
│0│b│
│1│a│
╰───┴───╯

Prepend one integer item

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

Prepend two integer items

> [234] |prepend [01]
╭───┬───╮
│0│0│
│1│1│
│2│2│
│3│3│
│4│4│
╰───┴───╯

Prepend integers and strings

> [2nu4shell] |prepend [01rocks]
╭───┬───────╮
│0│0│
│1│1│
│2│rocks│
│3│2│
│4│nu│
│5│4│
│6│shell│
╰───┴───────╯

Prepend a range

> [34] |prepend0..2
╭───┬───╮
│0│0│
│1│1│
│2│2│
│3│3│
│4│4│
╰───┴───╯

Notes

Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it, and you want the variable's contents to be prepended without being unwrapped, it's wise to pre-emptively wrap the variable in a list, like so: prepend [$val]. This way, prepend will only unwrap the outer list, and leave the variable's contents untouched.

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