Sortix 1.1dev ports manual
This manual documents Sortix 1.1dev ports. You can instead view this document in the latest official manual.
SORT(1) | General Commands Manual | SORT(1) |
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. The options are as follows:- -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. sort reads the whole input into memory, rather than storing intermediate sorting steps in the filesystem, and requires enough memory to store a copy of the whole input.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
SEE ALSO
cat(1), comm(1), join(1), uniq(1), qsort(3), strcoll(3), strverscmp(3)STANDARDS
sort is standardized in IEEE Std 1003.1-2008 (“POSIX.1”), which is currently partially implemented in this implementation of sort. The -R, -V, and -z options, as well as the long options, are extensions also found in GNU coreutils. Unlike GNU coreutils, -R will not remove duplicates unless -u is passed. As an extension, the -C and -c options support multiple input files.BUGS
The IEEE Std 1003.1-2008 (“POSIX.1”) options -b, -d, -f, -i, -k, -n, and -t are not currently implemented. The -m option is not currently taken advantage of to speed up the sorting, rather the presorted input files are sorted all over again.April 8, 2018 | Debian |