16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sort<br />

Sorting Keys<br />

By default, sort examines entire input records to determine ordering. By specifying<br />

sorting keys on the command line, you can tell sort to restrict its attention to one or<br />

more parts of each record.<br />

You can indicate the start of a sorting key with:<br />

-k m[.n][options]<br />

where m and the optional n are positive integers. You can choose options from the<br />

set bdfiMnr (described previously) to specify the way in which sort does<br />

comparisons for that sorting key. Ordering options set for a key override global<br />

ordering options. If you do not specify any options for the key, the global ordering<br />

options are used.<br />

The number m specifies which field in the input record contains the start of the<br />

sorting key. The character given with the –t option separates input fields; if this<br />

option is not specified, spaces or tabs separate the fields. The resulting sort key is<br />

from the mth field to the end of the record. The number n specifies which character<br />

in the mth field marks the start of the sorting key; if you do not specify n, the sorting<br />

key starts at the first character of the mth field.<br />

If an ending position for a key is not specified, the sorting key extends from the<br />

starting position to the end of the input record. You can also specify an ending<br />

position for a key, with:<br />

-k m[.n][options],<br />

p[.q][options]<br />

where p and q are positive integers, indicating that the sort key ends with the with<br />

qth character of the pth field. If you do not specify q or if you specify a value of 0<br />

for q, the sorting key ends at the last character of the pth field. For example:<br />

-k 2.3,4.6<br />

defines a sorting key that extends from the third character of the second field to the<br />

sixth character of the fourth field. The b option applies only the key start or key end<br />

for which it is specified;<br />

-k 2<br />

defines a sorting key that extends from the first character of the second field to the<br />

end of the record;<br />

-k2 2<br />

defines a sorting key that extends from the first character of the second field to the<br />

last character of the second field.<br />

sort also supports a historical method of defining the sorting key. Using this<br />

method, you indicate the start of the sorting key with:<br />

+m[.n][options]<br />

which is equivalent to:<br />

–k m+1[.n+1][options]<br />

You can also indicate the end of a sorting key with:<br />

–p[.q][options]<br />

590 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!