Sort lines of text files.

Synopsis

sort [OPTION]... [FILE]...

Description

Sort lines of text from files or standard input and write the result to standard output. By default, sorts in ascending lexicographic order. Runs in the just-bash WASM shell inside SLICC.

Options

-n, --numeric-sort Compare according to string numerical value.

-r, --reverse Reverse the result of comparisons.

-u, --unique Output only unique lines.

-k, --key=KEYDEF Sort via a key.

-t, --field-separator=SEP Use SEP as the field separator.

--help Display help and exit.

Examples

$ sort names.txt

Sort lines alphabetically.

$ sort -n -r scores.txt

Sort numerically in reverse order.

$ sort -t',' -k2 data.csv

Sort CSV by second field.

$ sort -u words.txt

Sort and remove duplicate lines.

Notes

Operates on the SLICC virtual filesystem (LightningFS/IndexedDB). Reads from standard input if no files are specified.

See Also

uniq, wc, cut, awk