commands
sort — sort text lines
Sort according to locale or selected keys; -n compares leading numeric values, -r reverses comparison, -u emits unique comparison keys. Never redirect output to the same input. Example assumes a fresh text-streams lab fixture.
Formal Syntax & Structure
linux syntaxlinux
sort [OPTION]... [FILE]...Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -n | option | Numeric comparison |
| -r | option | Reverse |
| -u | option | Unique comparison keys |
| FILE | operand | Input file |
Return Value
exit status and output
For GNU sort, status 0 indicates successful sorting or a successful order check. With -c (check order rather than sort), status 1 reports unsorted input; status 2 reports an error. Inspect stderr for diagnostics.
Working Example
Example Snippetlinux
LC_ALL=C sort -n numbers.txt