skaembutils
Software
www.skarnet.org
The sort program
sort sorts files line by line.
Interface
sort [ -bfrcuz ] [ file... ]
- sort will read every file, sort all lines
according to the given options, then print the sorted lines on
stdout and exit 0.
- If it encounters a hard error, sort exits 111.
- If file is -, or there is no file,
sort reads stdin.
Options
- -b : ignore leading blanks (spaces and tabs)
- -f : ignore case for alphabetic characters
- -r : reverse the result of comparisons
- -c : don't print anything, only check whether
the files are sorted. Exit 0 if they are, 1 otherwise.
- -u : with -c: check for strict ordering.
Otherwise: on output discard all but one of successive identical
(according to the comparison options) lines.
- -z : read and write zero-terminated lines, instead
of newline-terminated ones.
Notes
sort slurps all files into memory before sorting the
lines. Therefore it's unsuitable for very large files, especially
on embedded systems where memory requirements are tight. It's very
efficient and cheap for small and average-sized files though.
When you run GNU sort (even without options), it begins by allocating
24 megabytes of memory before anything else. This behaviour is
completely unacceptable. If 10 shell scripts run sort
simultaneously, will the machine keep up ? skaembutils
sort is of course immune to this.