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

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:

inputoutput
anylist<any>

Examples

prepend a list to an item

> 0 | prepend [1 2 3]
╭───┬───╮
│ 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 int item

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

Prepend two int items

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

Prepend ints and strings

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

Prepend a range

> [3 4] | prepend 0..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.