sort—sorts and/or merges files
sort [ –cmu ] [ –ooutput ] [ –T directory ] [ –ykmem ]
[ –dfiMnr ] [ –btx ] [ +pos1 [ –pos2 ]] [ filename...]
The sort command sorts (ASCII) lines of all the named files together and writes the result on the standard output. Comparisons are based on one or more sort keys extracted from each line of input. By default, there is one sort key, the entire input line, and ordering is lexicographic by bytes in machine collating sequence.
Example A.51.
1 sort filename
2 sort -u filename
3 sort -r filename
4 sort +1 -2 filename
5 sort -2n filename
6 sort -t: +2n -3 filename
7 sort -f filename
8 sort -b +1 filename
EXPLANATION
Sorts the lines alphabetically. Sorts out duplicate entries. Sorts starting on field 1 (fields are separated by whitespace and start at field 0), stopping at field 2 rather than sorting to the end of the line. Sorts the third field numerically. Sorts numerically starting at field 2 and stopping at field 3, with the colon designated as the field separator (–t:). Sorts folding in uppercase and lowercase letters. Sorts starting at field 1, removing leading blanks.
|