Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

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 dened 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 dened by the current set-
ting of the LC_COLLATE environment variable. The conguration les for collation and char-
acter classication information are /usr/lib/nls/loc/src/
locale.src.
A eld is one or more characters bounded by the beginning of a line and the current eld separa-
tor, or one or more characters bounded by a eld separator on either side. The space character is
the default eld separator.
Lines longer than 1024 bytes are truncated by sort. The maximum number of elds on a line is
10.
EXAMPLES
The following examples apply to the C locale, unless it is specically 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-004 Hewlett-Packard Company 847