MPE/iX Shell and Utilities Reference Manual, Vol 2
sort(1) MPE/iX Shell and Utilities sort(1)
Sorting Keys
By default, sort examines entire input records to determine ordering. By specifying sorting
keys on the command line, you can tell sort to restrict its attention to one or more parts of
each record.
You can indicate the start of a sorting key with
–k m[.n][options]
where m and the optional n are positive integers. You can choose options from the set
bdfiMnr (described previously) to specify the way in which sort does comparisons for that
sorting key. When you set one or more ordering options for a key, sort uses those options in-
stead of the global ordering options for that key. If you do not specify any options for the key,
the global ordering options are used.
The number m specifies which field in the input record contains the start of the sorting key.
The character given with the –t option separates input fields; if this option is not given,
spaces or tabs separates the fields. The number n specifies which character in the nth field
marks the start of the sorting key; if you do not specify n, the sorting key starts at the first
character of the mth field.
You can also specify an ending position for a key, with
-k m[.n][options],p[.q][options]
where p and q are positive integers, indicating that the sort key ends with the with qth charac-
ter of the pth field. If you do not specify q or you specify a value of 0 for q, the sorting key
ends at the last character of the pth field. For example,
-k 2.3,4.6
defines a sorting key that extends from the third character of the second field to the sixth char-
acter of the fourth field.
sort also supports a historical method of defining the sorting key. Using this method, you
indicate the start of the sorting key with
+m[.n][options]
which is equivalent to
–k m+1[.n+1][options]
You can also indicate the end of a sorting key with
–p[.q][options]
Commands and Utilities 1-561