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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples<br />

which when preceded with +m[.n] is equivalent to:<br />

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

if q is specified and is zero. Otherwise,<br />

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

For example:<br />

+1.2 -3.5<br />

defines a sorting key with a starting position that sort finds by skipping the first two<br />

characters of the next field and an ending position that sort finds by skipping the<br />

first three fields and then the first five characters of the next field. In other words,<br />

the sorting key extends from the third character of the second field to the sixth<br />

character of the fourth field. This is the same key as defined under the –k option,<br />

described earlier.<br />

With either syntax, if the end of a sorting key is not a valid position after the<br />

beginning key position, the sorting key extends to the end of the input record.<br />

You can specify multiple sort key positions by using several –k options or several +<br />

and – options. In this case, sort uses the second sorting key only for records where<br />

the first sorting keys are equal, the third sorting key only when the first two are<br />

equal, and so on. If all key positions compare equal, sort determines ordering by<br />

using the entire record.<br />

When you specify the –u option to determine the uniqueness of output records,<br />

sort looks only at the sorting keys, not the whole record. (Of course, if you specify<br />

no sorting keys, sort considers the whole record to be the sorting key.)<br />

1. To sort an input file having lines consisting of the day of the month, white space,<br />

and the month, as in:<br />

30 December<br />

23 MAY<br />

25 June<br />

10 June<br />

use the command:<br />

sort -k 2M -k 1n<br />

2. To merge two dictionaries, with one word per line:<br />

sort –m –dfi dict1 dict2 >newdict<br />

Environment Variable<br />

sort uses the following environment variable:<br />

File<br />

TMPDIR<br />

Contains the pathname of the directory to be used for temporary files.<br />

sort uses the following file:<br />

sort<br />

/tmp/stm*<br />

Temporary files used for merging and –o option. You can specify a different<br />

directory for temporary files using the TMPDIR environment variable.<br />

Chapter 2. Shell command descriptions 591

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

Saved successfully!

Ooh no, something went wrong!