sort command

The sort command, which puts lines in order, alphabetically by default.

In more detail

-n sorts by numeric value, -r reverses, -k picks a key column with -t setting the separator, and -u drops duplicates. -o file writes the result safely back over an input file, which a plain > redirect would empty first.

Examples

sort -t, -k3 -n sales.csv
sort names.txt -o names.txt

Related terms

Taught in

References