Skip to content

Instantly share code, notes, and snippets.

@arashout
Last active July 13, 2020 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arashout/3f8e754f43de65702fa75c53a13f1313 to your computer and use it in GitHub Desktop.
Save arashout/3f8e754f43de65702fa75c53a13f1313 to your computer and use it in GitHub Desktop.
title layout
Documentation
doc

We have a few good resources for you to get started with Nu.

At the bottom of this page you can also find quick references to the commands provided by Nu Shell if you need quick support.

Books

Nu Book

You can read our book to learn more about the core concepts behind Nu. It covers the basic and contains a lot of examples which will help you to have an easy start.

Contributor Book

In the contributors book you can find further information. It attempts to cover the basics of how Nu works internally, to get a solid understanding. You will learn how data is treated, what kind of data types Nu supports and how you can write plugins for it.

Cookbook

Nu Cookbook is a collection of examples to help you get the most out of using Nushell. It offers multiple ways of expressing the same pipelines so you can become familiar with all the commands.

Command Reference

alias - Define a shortcut for another command.

Detailed doc

Define a shortcut for another command.

Usage:

alias {flags}

Parameters:
the name of the alias
the arguments to the alias
the block to run as the body of the alias

Flags:
-h, --help: Display this help message
-s, --save: save the alias to your config

Examples:
An alias without parameters

alias say-hi [] { echo 'Hello!' }

An alias with a single parameter

alias l [x] { ls $x }

ansi - Output ANSI codes to change color

Output ANSI codes to change color

Usage:

ansi {flags}

Parameters:
the name of the color to use or 'reset' to reset the color

Flags:
-h, --help: Display this help message

Examples:
Change color to green

ansi green

Reset the color

ansi reset

append - Append the given row to the table

Detailed doc

Append the given row to the table

Usage:

append {flags}

Parameters:
the value of the row to append to the table

Flags:
-h, --help: Display this help message

Examples:
Add something to the end of a list or table

echo [1 2 3] | append 4

autoenv - Manage directory specific environments

Manage directory specific environments

Usage:

autoenv {flags}

Flags:
-h, --help: Display this help message

Examples:
Allow .nu-env file in current directory

autoenv trust

  • autoenv trust - Manage directory specific environments

    Manage directory specific environments

    Usage:

    autoenv {flags}

    Flags:
    -h, --help: Display this help message

    Examples:
    Allow .nu-env file in current directory

    autoenv trust

  • autoenv untrust - Manage directory specific environments

    Manage directory specific environments

    Usage:

    autoenv {flags}

    Flags:
    -h, --help: Display this help message

    Examples:
    Allow .nu-env file in current directory

    autoenv trust

autoview - View the contents of the pipeline as a table or list.

Detailed doc

View the contents of the pipeline as a table or list.

Usage:

autoview {flags}

Flags:
-h, --help: Display this help message

Examples:
Automatically view the results

ls | autoview

Autoview is also implied. The above can be written as

ls

binaryview - Autoview of binary data.

Autoview of binary data.

Usage:

binaryview {flags}

Flags:
-h, --help: Display this help message
-l, --lores: use low resolution output mode

build-string - Builds a string from the arguments

Builds a string from the arguments

Usage:

build-string ...args{flags}

Parameters:
...args: all values to form into the string

Flags:
-h, --help: Display this help message

Examples:
Builds a string from a string and a number, without spaces between them

build-string 'foo' 3

cal - Display a calendar.

Detailed doc

Display a calendar.

Usage:

cal {flags}

Flags:
-h, --help: Display this help message
-y, --year: Display the year column
-q, --quarter: Display the quarter column
-m, --month: Display the month column
--full-year : Display a year-long calendar for the specified year
--week-start : Display the calendar with the specified day as the first day of the week
--month-names: Display the month names instead of integers

Examples:
This month's calendar

cal

The calendar for all of 2012

cal --full-year 2012

This month's calendar with the week starting on monday

cal --week-start monday

calc - Parse a math expression into a number

Detailed doc

Parse a math expression into a number

Usage:

calc {flags}

Flags:
-h, --help: Display this help message

Examples:
Calculate math in the pipeline

echo '10 / 4' | calc

cd - Change to a new path.

Detailed doc

Change to a new path.

Usage:

cd (directory) {flags}

Parameters:
(directory) the directory to change to

Flags:
-h, --help: Display this help message

Examples:
Change to a new directory called 'dirname'

cd dirname

Change to your home directory

cd

Change to your home directory (alternate version)

cd ~

Change to the previous directory

cd -

char - Output special characters (eg. 'newline')

Output special characters (eg. 'newline')

Usage:

ansi {flags}

Parameters:
the name of the character to output

Flags:
-h, --help: Display this help message

Examples:
Output newline

char newline

clear - clears the terminal

clears the terminal

Usage:

clear {flags}

Flags:
-h, --help: Display this help message

Examples:
Clear the screen

clear

clip - Copy the contents of the pipeline to the copy/paste buffer

Copy the contents of the pipeline to the copy/paste buffer

Usage:

clip {flags}

Flags:
-h, --help: Display this help message

Examples:
Save text to the clipboard

echo 'secret value' | clip

compact - Creates a table with non-empty rows

Detailed doc

Creates a table with non-empty rows

Usage:

compact ...args{flags}

Parameters:
...args: the columns to compact from the table

Flags:
-h, --help: Display this help message

Examples:
Filter out all null entries in a list

echo [1 2 $null 3 $null $null] | compact

Filter out all directory entries having no 'target'

ls -af | compact target

config - Configuration management.

Detailed doc

Configuration management.

Usage:

config {flags}

Flags:
-h, --help: Display this help message
-l, --load : load the config from the path given
-s, --set : set a value in the config, eg) --set [key value]
-i, --set_into : sets a variable from values in the pipeline
-g, --get : get a value from the config
-r, --remove : remove a value from the config
-c, --clear: clear the config
-p, --path: return the path to the config file

Examples:
See all config values

config

Set completion_mode to circular

config --set [completion_mode circular]

Store the contents of the pipeline as a path

echo ['/usr/bin' '/bin'] | config --set_into path

Get the current startup commands

config --get startup

Remove the startup commands

config --remove startup

Clear the config (be careful!)

config --clear

Get the path to the current config file

config --path

count - Show the total number of rows or items.

Detailed doc

Show the total number of rows or items.

Usage:

count {flags}

Flags:
-h, --help: Display this help message

Examples:
Count the number of entries in a list

echo [1 2 3 4 5] | count

cp - Copy files.

Copy files.

Usage:

cp {flags}

Parameters:
the place to copy from
the place to copy to

Flags:
-h, --help: Display this help message
-r, --recursive: copy recursively through subdirectories

Examples:
Copy myfile to dir_b

cp myfile dir_b

Recursively copy dir_a to dir_b

cp -r dir_a dir_b

date - Get the current datetime.

Detailed doc

Get the current datetime.

Usage:

date {flags}

Flags:
-h, --help: Display this help message
-u, --utc: use universal time (UTC)
-l, --local: use the local time
-f, --format : report datetime in supplied strftime format
-r, --raw: print date without tables

Examples:
Get the current local time and date

date

Get the current UTC time and date

date --utc

Get the current time and date and report it based on format

date --format '%Y-%m-%d %H:%M:%S.%f %z'

Get the current time and date and report it without a table

date --format '%Y-%m-%d %H:%M:%S.%f %z' --raw

debug - Print the Rust debug representation of the values

Detailed doc

Print the Rust debug representation of the values

Usage:

debug {flags}

Flags:
-h, --help: Display this help message
-r, --raw: Prints the raw value representation.

default - Sets a default row's column if missing.

Detailed doc

Sets a default row's column if missing.

Usage:

default {flags}

Parameters:
the name of the column
the value of the column to default

Flags:
-h, --help: Display this help message

Examples:
Give a default 'target' to all file entries

ls -af | default target 'nothing'

describe - Describes the objects in the stream.

Describes the objects in the stream.

Usage:

describe {flags}

Flags:
-h, --help: Display this help message

do - Runs a block, optionally ignoring errors

Runs a block, optionally ignoring errors

Usage:

with-env {flags}

Parameters:
the block to run

Flags:
-h, --help: Display this help message
-i, --ignore_errors: ignore errors as the block runs

Examples:
Run the block

do { echo hello }

Run the block and ignore errors

do -i { thisisnotarealcommand }

drop - Drop the last number of rows.

Drop the last number of rows.

Usage:

drop (rows) {flags}

Parameters:
(rows) starting from the back, the number of rows to drop

Flags:
-h, --help: Display this help message

Examples:
Remove the last item of a list/table

echo [1 2 3] | drop

Remove the last 2 items of a list/table

echo [1 2 3] | drop 2

du - Find disk usage sizes of specified items

Detailed doc

Find disk usage sizes of specified items

Usage:

du (path) {flags}

Parameters:
(path) starting directory

Flags:
-h, --help: Display this help message
-a, --all: Output file sizes as well as directory sizes
-r, --deref: Dereference symlinks to their targets for size
-x, --exclude : Exclude these file names
-d, --max-depth : Directory recursion limit
-m, --min-size : Exclude files below this size

Examples:
Disk usage of the current directory

du

each - Run a block on each row of the table.

Run a block on each row of the table.

Usage:

each {flags}

Parameters:
the block to run on each row

Flags:
-h, --help: Display this help message
-n, --numbered: returned a numbered item ($it.index and $it.item)

Examples:
Echo the sum of each row

echo [[1 2] [3 4]] | each { echo $it | math sum }

Echo the square of each integer

echo [1 2 3] | each { echo $(= $it * $it) }

Number each item and echo a message

echo ['bob' 'fred'] | each --numbered { echo {{$it.index}} is {{$it.item}} }

echo - Echo the arguments back to the user.

Detailed doc

Echo the arguments back to the user.

Usage:

echo ...args{flags}

Parameters:
...args: the values to echo

Flags:
-h, --help: Display this help message

Examples:
Put a hello message in the pipeline

echo 'hello'

Print the value of the special '$nu' variable

echo $nu

empty? - Checks emptiness. The last value is the replacement value for any empty column(s) given to check against the table.

Checks emptiness. The last value is the replacement value for any empty column(s) given to check against the table.

Usage:

empty? ...args{flags}

Parameters:
...args: the names of the columns to check emptiness followed by the replacement value.

Flags:
-h, --help: Display this help message

enter - Create a new shell and begin at this path.

Multiple encodings are supported for reading text files by using
the '--encoding ' parameter. Here is an example of a few:
big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5

For a more complete list of encodings please refer to the encoding_rs
documentation link at https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics

Detailed doc

Create a new shell and begin at this path.

Multiple encodings are supported for reading text files by using
the '--encoding ' parameter. Here is an example of a few:
big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5

For a more complete list of encodings please refer to the encoding_rs
documentation link at https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics

Usage:

enter {flags}

Parameters:
the location to create a new shell from

Flags:
-h, --help: Display this help message
-e, --encoding : encoding to use to open file

Examples:
Enter a path as a new shell

enter ../projectB

Enter a file as a new shell

enter package.json

Enters file with iso-8859-1 encoding

enter file.csv --encoding iso-8859-1

every - Show (or skip) every n-th row, starting from the first one.

Detailed doc

Show (or skip) every n-th row, starting from the first one.

Usage:

every {flags}

Parameters:
how many rows to skip between (and including) each row returned

Flags:
-h, --help: Display this help message
-s, --skip: skip the rows that would be returned, instead of selecting them

Examples:
Get every second row

echo [1 2 3 4 5] | every 2

Skip every second row

echo [1 2 3 4 5] | every 2 --skip

exit - Exit the current shell (or all shells)

Detailed doc

Exit the current shell (or all shells)

Usage:

exit {flags}

Flags:
-h, --help: Display this help message
-n, --now: exit out of the shell immediately

Examples:
Exit the current shell

exit

Exit all shells (exiting Nu)

exit --now

fetch - Load from a URL into a cell, convert to table if possible (avoid by appending '--raw')

Detailed doc

Load from a URL into a cell, convert to table if possible (avoid by appending '--raw')

Usage:

fetch {flags}

Parameters:
the URL to fetch the contents from

Flags:
-h, --help: Display this help message
-u, --user : the username when authenticating
-p, --password : the password when authenticating
-r, --raw: fetch contents as text rather than a table

first - Show only the first number of rows.

Detailed doc

Show only the first number of rows.

Usage:

first (rows) {flags}

Parameters:
(rows) starting from the front, the number of rows to return

Flags:
-h, --help: Display this help message

Examples:
Return the first item of a list/table

echo [1 2 3] | first

Return the first 2 items of a list/table

echo [1 2 3] | first 2

format - Format columns into a string using a simple pattern.

Detailed doc

Format columns into a string using a simple pattern.

Usage:

format {flags}

Parameters:
the pattern to output. Eg) "{foo}: {bar}"

Flags:
-h, --help: Display this help message

Examples:
Print filenames with their sizes

ls | format '{name}: {size}'

from - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

Detailed doc

Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

Usage:

from {flags}

Flags:
-h, --help: Display this help message

  • from bson - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from csv - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from csv

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from db - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from eml - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from ics - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from ics

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from ini - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from ini

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from json - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from json

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from ods - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from ods

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from sqlite - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from ssv - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from toml - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from toml

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from tsv - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from tsv

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from url - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from url

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from vcf - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from vcf

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from xlsx - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from xlsx

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from xml - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from xml

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from yaml - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Detailed Doc for from yaml

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

  • from yml - Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)

    Usage:

    from {flags}

    Flags:
    -h, --help: Display this help message

get - Open given cells as text.

Detailed doc

Open given cells as text.

Usage:

get ...args{flags}

Parameters:
...args: optionally return additional data by path

Flags:
-h, --help: Display this help message

Examples:
Extract the name of files as a list

ls | get name

Extract the cpu list from the sys information

sys | get cpu

group-by - Creates a new table with the data from the table rows grouped by the column given.

Detailed doc

Creates a new table with the data from the table rows grouped by the column given.

Usage:

group-by (column_name) {flags}

Parameters:
(column_name) the name of the column to group by

Flags:
-h, --help: Display this help message

Examples:
Group items by type

ls | group-by type

Group items by their value

echo [1 3 1 3 2 1 1] | group-by

  • group-by date - Creates a new table with the data from the table rows grouped by the column given.

    Creates a new table with the data from the table rows grouped by the column given.

    Usage:

    group-by (column_name) {flags}

    Parameters:
    (column_name) the name of the column to group by

    Flags:
    -h, --help: Display this help message

    Examples:
    Group items by type

    ls | group-by type

    Group items by their value

    echo [1 3 1 3 2 1 1] | group-by

headers - Use the first row of the table as column names

Detailed doc

Use the first row of the table as column names

Usage:

headers {flags}

Flags:
-h, --help: Display this help message

Examples:
Create headers for a raw string

echo "a b c|1 2 3" | split row "|" | split column " " | headers

help - Display help information about commands.

Detailed doc

Display help information about commands.

Usage:

help ...args{flags}

Parameters:
...args: the name of command to get help on

Flags:
-h, --help: Display this help message

histogram - Creates a new table with a histogram based on the column name passed in.

Detailed doc

Creates a new table with a histogram based on the column name passed in.

Usage:

histogram <column_name> ...args{flags}

Parameters:
<column_name> the name of the column to graph by
...args: column name to give the histogram's frequency column

Flags:
-h, --help: Display this help message

Examples:
Get a histogram for the types of files

ls | histogram type

Get a histogram for the types of files, with frequency column named count

ls | histogram type count

Get a histogram for a list of numbers

echo [1 2 3 1 1 1 2 2 1 1] | histogram

history - Display command history.

Detailed doc

Display command history.

Usage:

history {flags}

Flags:
-h, --help: Display this help message

if - Filter table to match the condition.

Filter table to match the condition.

Usage:

if <then_case> <else_case> {flags}

Parameters:
the condition that must match
<then_case> block to run if condition is true
<else_case> block to run if condition is false

Flags:
-h, --help: Display this help message

Examples:
Run a block if a condition is true

echo 10 | if $it > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }

Run a block if a condition is false

echo 1 | if $it > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }

inc - Increment a value or version. Optionally use the column of a table.

Detailed doc

Increment a value or version. Optionally use the column of a table.

Usage:

inc ...args{flags}

Parameters:
...args: the column(s) to update

Flags:
-h, --help: Display this help message
-M, --major: increment the major version (eg 1.2.1 -> 2.0.0)
-m, --minor: increment the minor version (eg 1.2.1 -> 1.3.0)
-p, --patch: increment the patch version (eg 1.2.1 -> 1.2.2)

insert - Insert a new column with a given value.

Detailed doc

Insert a new column with a given value.

Usage:

insert {flags}

Parameters:
the column name to insert
the value to give the cell(s)

Flags:
-h, --help: Display this help message

keep - Keep the number of rows only

Keep the number of rows only

Usage:

keep (rows) {flags}

Parameters:
(rows) starting from the front, the number of rows to keep

Flags:
-h, --help: Display this help message

Examples:
Keep the first row

echo [1 2 3] | keep

Keep the first four rows

echo [1 2 3 4 5] | keep 4

keep-until - Keeps rows until the condition matches.

Keeps rows until the condition matches.

Usage:

keep-until {flags}

Parameters:
the condition that must be met to stop keeping rows

Flags:
-h, --help: Display this help message

keep-while - Keeps rows while the condition matches.

Keeps rows while the condition matches.

Usage:

keep-while {flags}

Parameters:
the condition that must be met to keep rows

Flags:
-h, --help: Display this help message

kill - Kill a process using the process id.

Kill a process using the process id.

Usage:

kill ...args{flags}

Parameters:
process id of process that is to be killed
...args: rest of processes to kill

Flags:
-h, --help: Display this help message
-f, --force: forcefully kill the process
-q, --quiet: won't print anything to the console

Examples:
Kill the pid using the most memory

ps | sort-by mem | last | kill $it.pid

Force kill a given pid

kill --force 12345

last - Show only the last number of rows.

Detailed doc

Show only the last number of rows.

Usage:

last (rows) {flags}

Parameters:
(rows) starting from the back, the number of rows to return

Flags:
-h, --help: Display this help message

Examples:
Get the last row

echo [1 2 3] | last

Get the last three rows

echo [1 2 3 4 5] | last 3

lines - Split single string into rows, one per line.

Detailed doc

Split single string into rows, one per line.

Usage:

lines {flags}

Flags:
-h, --help: Display this help message

Examples:
Split multi-line string into lines

^echo "two\nlines" | lines

ls - View the contents of the current or given path.

View the contents of the current or given path.

Usage:

ls (path) {flags}

Parameters:
(path) a path to get the directory contents from

Flags:
-h, --help: Display this help message
-a, --all: also show hidden files
-f, --full: list all available columns for each entry
-s, --short-names: only print the file names and not the path
-w, --with-symlink-targets: display the paths to the target files that symlinks point to
-d, --du: display the apparent directory size in place of the directory metadata size

Examples:
List all files in the current directory

ls

List all files in a subdirectory

ls subdir

List all rust files

ls *.rs

match - filter rows by regex

filter rows by regex

Usage:

match {flags}

Parameters:
the column name to match
the regex to match with

Flags:
-h, --help: Display this help message

math - Use mathematical functions as aggregate functions on a list of numbers or tables

Detailed doc

Use mathematical functions as aggregate functions on a list of numbers or tables

Usage:

math {flags}

Flags:
-h, --help: Display this help message

  • math avg - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

  • math max - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

  • math median - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

  • math min - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

  • math mode - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

  • math sum - Use mathematical functions as aggregate functions on a list of numbers or tables

    Use mathematical functions as aggregate functions on a list of numbers or tables

    Usage:

    math {flags}

    Flags:
    -h, --help: Display this help message

merge - Merge a table.

Merge a table.

Usage:

merge {flags}

Parameters:
the block to run and merge into the table

Flags:
-h, --help: Display this help message

Examples:
Merge a 1-based index column with some ls output

ls | select name | keep 3 | merge { echo [1 2 3] | wrap index }

mkdir - Make directories, creates intermediary directories as required.

Make directories, creates intermediary directories as required.

Usage:

mkdir ...args{flags}

Parameters:
...args: the name(s) of the path(s) to create

Flags:
-h, --help: Display this help message
-s, --show-created-paths: show the path(s) created.

Examples:
Make a directory named foo

mkdir foo

move - moves across desired subcommand.

moves across desired subcommand.

Usage:

move {flags}

Flags:
-h, --help: Display this help message

  • move column - moves across desired subcommand.

    moves across desired subcommand.

    Usage:

    move {flags}

    Flags:
    -h, --help: Display this help message

mv - Move files or directories.

Move files or directories.

Usage:

mv {flags}

Parameters:

the location to move files/directories from the location to move files/directories to

Flags:
-h, --help: Display this help message

Examples:
Rename a file

mv before.txt after.txt

Move a file into a directory

mv test.txt my/subdirectory

Move many files into a directory

mv *.txt my/subdirectory

n - Go to next shell.

Go to next shell.

Usage:

n {flags}

Flags:
-h, --help: Display this help message

nth - Return only the selected rows

Detailed doc

Return only the selected rows

Usage:

nth ...args{flags}

Parameters:
the number of the row to return
...args: Optionally return more rows

Flags:
-h, --help: Display this help message

Examples:
Get the second row

echo [first second third] | nth 1

Get the first and third rows

echo [first second third] | nth 0 2

open - Load a file into a cell, convert to table if possible (avoid by appending '--raw').

Multiple encodings are supported for reading text files by using
the '--encoding ' parameter. Here is an example of a few:
big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5

For a more complete list of encodings please refer to the encoding_rs
documentation link at https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics

Detailed doc

Load a file into a cell, convert to table if possible (avoid by appending '--raw').

Multiple encodings are supported for reading text files by using
the '--encoding ' parameter. Here is an example of a few:
big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5

For a more complete list of encodings please refer to the encoding_rs
documentation link at https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics

Usage:

open {flags}

Parameters:
the file path to load values from

Flags:
-h, --help: Display this help message
-r, --raw: load content as a string instead of a table
-e, --encoding : encoding to use to open file

Examples:
Opens "users.csv" and creates a table from the data

open users.csv

Opens file with iso-8859-1 encoding

open file.csv --encoding iso-8859-1 | from csv

p - Go to previous shell.

Go to previous shell.

Usage:

p {flags}

Flags:
-h, --help: Display this help message

parse - Parse columns from string data using a simple pattern.

Parse columns from string data using a simple pattern.

Usage:

parse {flags}

Parameters:
the pattern to match. Eg) "{foo}: {bar}"

Flags:
-h, --help: Display this help message
-r, --regex: use full regex syntax for patterns

pivot - Pivots the table contents so rows become columns and columns become rows.

Detailed doc

Pivots the table contents so rows become columns and columns become rows.

Usage:

pivot ...args{flags}

Parameters:
...args: the names to give columns once pivoted

Flags:
-h, --help: Display this help message
-r, --header-row: treat the first row as column names
-i, --ignore-titles: don't pivot the column names into values

post - Post content to a url and retrieve data as a table if possible.

Post content to a url and retrieve data as a table if possible.

Usage:

post {flags}

Parameters:
the URL to post to

the contents of the post body

Flags:
-h, --help: Display this help message
-u, --user : the username when authenticating
-p, --password : the password when authenticating
-t, --content-type : the MIME type of content to post
-l, --content-length : the length of the content being posted
-r, --raw: return values as a string instead of a table

prepend - Prepend the given row to the front of the table

Detailed doc

Prepend the given row to the front of the table

Usage:

prepend {flags}

Parameters:
the value of the row to prepend to the table

Flags:
-h, --help: Display this help message

Examples:
Add something to the beginning of a list or table

echo [2 3 4] | prepend 1

ps - View information about system processes.

Detailed doc

View information about system processes.

Usage:

ps {flags}

Flags:
-h, --help: Display this help message
-f, --full: list all available columns for each entry

pwd - Output the current working directory.

Detailed doc

Output the current working directory.

Usage:

pwd {flags}

Flags:
-h, --help: Display this help message

Examples:
Print the current working directory

pwd

random - Generate random values

Detailed doc

Generate random values

Usage:

random {flags}

Flags:
-h, --help: Display this help message

  • random bool - Generate random values

    Generate random values

    Usage:

    random {flags}

    Flags:
    -h, --help: Display this help message

  • random dice - Generate random values

    Generate random values

    Usage:

    random {flags}

    Flags:
    -h, --help: Display this help message

  • random uuid - Generate random values

    Generate random values

    Usage:

    random {flags}

    Flags:
    -h, --help: Display this help message

range - Return only the selected rows

Return only the selected rows

Usage:

range {flags}

Parameters:
range of rows to return: Eg) 4..7 (=> from 4 to 7)

Flags:
-h, --help: Display this help message

reject - Remove the given columns from the table.

Detailed doc

Remove the given columns from the table.

Usage:

reject ...args{flags}

Parameters:
...args: the names of columns to remove

Flags:
-h, --help: Display this help message

Examples:
Lists the files in a directory without showing the modified column

ls | reject modified

rename - Creates a new table with columns renamed.

Detailed doc

Creates a new table with columns renamed.

Usage:

rename <column_name> ...args{flags}

Parameters:
<column_name> the new name for the first column
...args: the new name for additional columns

Flags:
-h, --help: Display this help message

Examples:
Rename a column

echo "{a: 1, b: 2, c: 3}" | from json | rename my_column

Rename many columns

echo "{a: 1, b: 2, c: 3}" | from json | rename spam eggs cars

reverse - Reverses the table.

Detailed doc

Reverses the table.

Usage:

reverse {flags}

Flags:
-h, --help: Display this help message

Examples:
Sort list of numbers in descending file size

echo [3 1 2 19 0] | reverse

rm - Remove file(s)

Remove file(s)

Usage:

rm ...args{flags}

Parameters:
...args: the file path(s) to remove

Flags:
-h, --help: Display this help message
-t, --trash: use the platform's recycle bin instead of permanently deleting
-p, --permanent: don't use recycle bin, delete permanently
-r, --recursive: delete subdirectories recursively

Examples:
Delete or move a file to the system trash (depending on 'rm_always_trash' config option)

rm file.txt

Move a file to the system trash

rm --trash file.txt

Delete a file permanently

rm --permanent file.txt

run_external -

Usage:

run_external ...args{flags}

Parameters:
...args: external command arguments

Flags:
-h, --help: Display this help message

save - Save the contents of the pipeline to a file.

Detailed doc

Save the contents of the pipeline to a file.

Usage:

save (path) {flags}

Parameters:
(path) the path to save contents to

Flags:
-h, --help: Display this help message
-r, --raw: treat values as-is rather than auto-converting based on file extension

select - Down-select table to only these columns.

Detailed doc

Down-select table to only these columns.

Usage:

select ...args{flags}

Parameters:
...args: the columns to select from the table

Flags:
-h, --help: Display this help message

Examples:
Select just the name column

ls | select name

Select the name and size columns

ls | select name size

shells - Display the list of current shells.

Detailed doc

Display the list of current shells.

Usage:

shells {flags}

Flags:
-h, --help: Display this help message

shuffle - Shuffle rows randomly.

Detailed doc

Shuffle rows randomly.

Usage:

shuffle {flags}

Flags:
-h, --help: Display this help message

size - Gather word count statistics on the text.

Detailed doc

Gather word count statistics on the text.

Usage:

size {flags}

Flags:
-h, --help: Display this help message

Examples:
Count the number of words in a string

echo "There are seven words in this sentence" | size

skip - Skip some number of rows.

Detailed doc

Skip some number of rows.

Usage:

skip (rows) {flags}

Parameters:
(rows) how many rows to skip

Flags:
-h, --help: Display this help message

Examples:
Skip the first 5 rows

echo [1 2 3 4 5 6 7] | skip 5

skip-until - Skips rows until the condition matches.

Skips rows until the condition matches.

Usage:

skip-until {flags}

Parameters:
the condition that must be met to stop skipping

Flags:
-h, --help: Display this help message

skip-while - Skips rows while the condition matches.

Detailed doc

Skips rows while the condition matches.

Usage:

skip-while {flags}

Parameters:
the condition that must be met to continue skipping

Flags:
-h, --help: Display this help message

sort-by - Sort by the given columns, in increasing order.

Detailed doc

Sort by the given columns, in increasing order.

Usage:

sort-by ...args{flags}

Parameters:
...args: the column(s) to sort by

Flags:
-h, --help: Display this help message

Examples:
Sort list by increasing value

echo [4 2 3 1] | sort-by

Sort output by increasing file size

ls | sort-by size

Sort output by type, and then by file size for each type

ls | sort-by type size

split - split contents across desired subcommand (like row, column) via the separator.

split contents across desired subcommand (like row, column) via the separator.

Usage:

split {flags}

Flags:
-h, --help: Display this help message

  • split chars - split contents across desired subcommand (like row, column) via the separator.

    split contents across desired subcommand (like row, column) via the separator.

    Usage:

    split {flags}

    Flags:
    -h, --help: Display this help message

  • split column - split contents across desired subcommand (like row, column) via the separator.

    Detailed Doc for split column

    split contents across desired subcommand (like row, column) via the separator.

    Usage:

    split {flags}

    Flags:
    -h, --help: Display this help message

  • split row - split contents across desired subcommand (like row, column) via the separator.

    Detailed Doc for split row

    split contents across desired subcommand (like row, column) via the separator.

    Usage:

    split {flags}

    Flags:
    -h, --help: Display this help message

split-by - Creates a new table with the data from the inner tables split by the column given.

Creates a new table with the data from the inner tables split by the column given.

Usage:

split-by (column_name) {flags}

Parameters:
(column_name) the name of the column within the nested table to split by

Flags:
-h, --help: Display this help message

start - Opens each file/directory/URL using the default application

Detailed doc

Opens each file/directory/URL using the default application

Usage:

start ...args{flags}

Parameters:
...args: files/urls/directories to open

Flags:
-h, --help: Display this help message
-a, --application : Specifies the application used for opening the files/directories/urls

str - Apply string function.

Detailed doc

Apply string function.

Usage:

str ...args{flags}

Parameters:
...args: optionally convert by column paths

Flags:
-h, --help: Display this help message

  • str capitalize - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str collect - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str downcase - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str find-replace - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str length - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str set - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str substring - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str to-datetime - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str to-decimal - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str to-int - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str trim - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

  • str upcase - Apply string function.

    Apply string function.

    Usage:

    str ...args{flags}

    Parameters:
    ...args: optionally convert by column paths

    Flags:
    -h, --help: Display this help message

sys - View information about the current system.

Detailed doc

View information about the current system.

Usage:

sys {flags}

Flags:
-h, --help: Display this help message

table - View the contents of the pipeline as a table.

View the contents of the pipeline as a table.

Usage:

table {flags}

Flags:
-h, --help: Display this help message
-n, --start_number : row number to start viewing from

tags - Read the tags (metadata) for values.

Detailed doc

Read the tags (metadata) for values.

Usage:

tags {flags}

Flags:
-h, --help: Display this help message

textview - Autoview of text data.

Autoview of text data.

Usage:

textview {flags}

Flags:
-h, --help: Display this help message

to - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

Detailed doc

Convert table into an output format (based on subcommand, like csv, html, json, yaml).

Usage:

to {flags}

Flags:
-h, --help: Display this help message

  • to bson - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to csv - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to csv

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to db - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to html - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to json - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to json

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to md - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to sqlite - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to toml - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to toml

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to tsv - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to tsv

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to url - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to url

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

  • to yaml - Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Detailed Doc for to yaml

    Convert table into an output format (based on subcommand, like csv, html, json, yaml).

    Usage:

    to {flags}

    Flags:
    -h, --help: Display this help message

touch - creates a file

Detailed doc

creates a file

Usage:

touch {flags}

Parameters:
the path of the file you want to create

Flags:
-h, --help: Display this help message

Examples:
Creates "fixture.json"

touch fixture.json

tree - View the contents of the pipeline as a tree.

View the contents of the pipeline as a tree.

Usage:

tree {flags}

Flags:
-h, --help: Display this help message

trim - Trim leading and following whitespace from text data.

Detailed doc

Trim leading and following whitespace from text data.

Usage:

trim {flags}

Flags:
-h, --help: Display this help message

Examples:
Trims surrounding whitespace and outputs "Hello world"

echo " Hello world" | trim

uniq - Return the unique rows

Detailed doc

Return the unique rows

Usage:

uniq {flags}

Flags:
-h, --help: Display this help message
-c, --count: Count the unique rows

update - Update an existing column to have a new value.

Detailed doc

Update an existing column to have a new value.

Usage:

update {flags}

Parameters:
the name of the column to update
the new value to give the cell(s)

Flags:
-h, --help: Display this help message

version - Display Nu version

Detailed doc

Display Nu version

Usage:

version {flags}

Flags:
-h, --help: Display this help message

Examples:
Display Nu version

version

where - Filter table to match the condition.

Detailed doc

Filter table to match the condition.

Usage:

where {flags}

Parameters:
the condition that must match

Flags:
-h, --help: Display this help message

Examples:
List all files in the current directory with sizes greater than 2kb

ls | where size > 2kb

List only the files in the current directory

ls | where type == File

List all files with names that contain "Car"

ls | where name =~ "Car"

List all files that were modified in the last two months

ls | where modified <= 2M

which - Finds a program file.

Detailed doc

Finds a program file.

Usage:

which {flags}

Parameters:
application

Flags:
-h, --help: Display this help message
-a, --all: list all executables

with-env - Runs a block with an environment set. Eg) with-env [NAME 'foo'] { echo $nu.env.NAME }

Runs a block with an environment set. Eg) with-env [NAME 'foo'] { echo $nu.env.NAME }

Usage:

with-env {flags}

Parameters:
the environment variable to temporarily set
the block to run once the variable is set

Flags:
-h, --help: Display this help message

Examples:
Set the MYENV environment variable

with-env [MYENV "my env value"] { echo $nu.env.MYENV }

wrap - Wraps the given data in a table.

Detailed doc

Wraps the given data in a table.

Usage:

wrap (column) {flags}

Parameters:
(column) the name of the new column

Flags:
-h, --help: Display this help message

Examples:
Wrap a list into a table with the default column name

echo [1 2 3] | wrap

Wrap a list into a table with a given column name

echo [1 2 3] | wrap MyColumn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment