Sortix cross-volatile manual
This manual documents Sortix cross-volatile. You can instead view this document in the latest official manual.
NAME
sort — sort lines of textSYNOPSIS
sort | [-CcmRruVz] [-o path] file ... |
DESCRIPTION
sort reads lines of text from the standard input and writes the lines in sorted order to the standard output. If files are specified, the input is the concatenated content of the files read in sequential order. The file path can be set to ‘-’ to specify the standard input. The lines are compared according to the current locale's collating rules.- -c, --check, --check=diagnose-first
- Check whether the input is already sorted. If a line is out of order (or an equal line is found if -u), write an error describing which line was out of order and exit 1.
- -C, --check=quiet, --check=silent
- Same as -c, but write no error to the standard output about the input being out of order.
- -m, --merge
- Merge the presorted input files into a sorted output.
- -o path, --output=path
- After reading the full input; write the output to the file at path (creating it if it does not already exist, discarding its previous contents if it already existed). The output file can be one of the input files. This option is incompatible with -C and -c.
- -R, --random-sort
- Sort the lines randomly with a uniform distribution, where all permutations are equally likely. This option is incompatible with -C and -c. If -u, don't write duplicate lines to the output.
- -r, --reverse
- Compare the lines in reverse order.
- -u, --unique
- Don't write a line if it is equal to the previous line.
- -V, --version-sort
- Sort according to the version string, per strverscmp(3).
- -z, --zero-terminated
- Lines are delimited with the NUL byte (0) instead of the newline byte (10).
IMPLEMENTATION NOTES
In the event of an input error, sort will write an error to the standard error and exit unsuccessfully.ENVIRONMENT
- LANG
- The default locale for locale variables that are unset or null.
- LC_ALL
- Overrides all the other locale variables if set.
- LC_COLLATE
- Compare the input according to this locale's collating rules using strcoll(3).
EXIT STATUS
sort will exit 0 on success, exit 1 if the input was out of order when -C or -c, or exit 2 (or higher) otherwise.EXAMPLES
Read lines from the standard input and write them in sorted order to the standard output:sort < input > output
grep pattern lines.txt | sort foo - bar -o output.txt
if sort -C file; [ $? = 1 ]; then sort file -o file fi
sort -u