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

sort(1) OSS Shell and Utilities Reference Manual
applied to all -k ags on the command line; otherwise, the -b ag can be independently
attached to each -k eld_start or eld_end argument.
-c Checks that the input is sorted according to the ordering rules specied in the ags and
the collating sequence of the current locale. No output is produced; only the exit code
is affected.
-d Species that only spaces and alphanumeric characters (according to the current set-
ting of LC_TYPE) are signicant in comparisons.
-f Treats all lowercase characters as their uppercase equivalents (according to the current
setting of LC_TYPE) for the purposes of comparison.
-i Sorts only by printable characters (according to the current setting of LC_TYPE).
-k keydef Species one or more (up to 10) restricted sort key eld denitions. This ag replaces
the obsolescent +fskip.cskip and -fskip.cskip ags. A eld comprises a maximal
sequence of non-separating characters and, in the absence of the
-t ag, any preceding
eld separator.
The format of a key eld denition is as follows:
eld_start[type][,eld_end[type]]
where the eld_start and eld_end arguments dene a key eld that is restricted to a
portion of the line, and type is a modier specied by b, d, f, i, n,orr. The b modier
behaves like the -b ag, but applies only to the eld_start or eld_end argument to
which it is attached. The other modiers behave like their corresponding ags, but
apply only to the key eld to which they are attached; these modiers have this effect if
specied with eld_start, eld_end or both. Modiers attached to a eld_start or
eld_end argument override any specications made by the ags. A missing eld_end
argument means the last character of the line.
The eld_start portion of the keydef argument takes the following form:
eld_number[.rst_character]
Fields and characters within elds are numbered starting with 1. The eld_number and
rst_character pieces, interpreted as positive decimal integers, specify the character to
be used as part of a sort key. If rst_character is not specied, the default is the rst
character of the eld.
The eld_end portion of the keydef argument takes the following form:
eld_number[.last_character]
The eld_number is the same as that described for eld_start. The last_character
argument, interpreted as a nonnegative decimal integer, species the last character to
be used as part of the sort key. If last_character evaluates to 0 (zero) or is not
specied, the default is the last character of the eld specied by eld_number.
If -b is in effect, characters within a eld are counted from the rst nonspace character
in the eld. (This applies separately to rst_character and last_character.)
If -k is not specied, the default sort key is the entire line.
When there are multiple key elds, later keys are compared only after all earlier keys
compare as equal. Except when the -u ag is specied, lines that otherwise compare as
equal are ordered as though none of the ags -d, -f, -i, -n,or-k were present (but with
-r still in effect, if it was specied) and with all bytes in the lines signicant to the
comparison.
The algorithm for the -k ag can be summarized as follows:
844 Hewlett-Packard Company 527188-004