Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (s) sort(1)
example, in German, the ß (scharfes-S) is collated as if it were ss.
N-to-One Character Mappings
Some languages treat a string of characters as if it were one single collating element. For exam-
ple, in Spanish, the ch and ll sequences are treated as their own elements within the alphabet.
(ch comes between c and d in the alphabet, and ll comes between l and m.)
Ignore-Character Mappings
In some cases, certain characters may be ignored in collation. For example, if - were defined as
an ignore-character, the strings
re-locate and relocate would sort to the same place.
The results that you get from sort depend on the collating sequence as defined by the current set-
ting of the LC_COLLATE environment variable. The configuration files for collation and char-
acter classification information are /usr/lib/nls/loc/src/
locale.src.
A field is one or more characters bounded by the beginning of a line and the current field separa-
tor, or one or more characters bounded by a field separator on either side. The space character is
the default field separator.
Lines longer than 1024 bytes are truncated by sort. The maximum number of fields on a line is
10.
EXAMPLES
The following examples apply to the C locale, unless it is specifically stated otherwise.
1. To perform a simple sort, enter:
sort fruits
This displays the contents of fruits sorted in ascending lexicographic order. This means
that the characters in each column are compared one by one, including spaces, digits, and
special characters.
For instance, if fruits contains the text:
banana
orange
Persimmon
apple
%%banana
apple
ORANGE
then sort fruits displays:
%%banana
ORANGE
Persimmon
apple
apple
banana
orange
This order follows from the fact that in the ASCII collating sequence, symbols (such as
%) precede uppercase letters, and all uppercase letters precede the lowercase letters. If
you are using a different collating order, your results may be different.
2. To group lines that contain uppercase and special characters with similar lowercase lines,
and remove duplicate lines, enter:
sort -d -f -u fruits
527188-007 Hewlett-Packard Company 8−51