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.

Options<br />

Examples<br />

Conceptually, join computes the Cartesian product of records from both files. By<br />

default, spaces or tabs separate input fields and join discards any leading or trailing<br />

white space. (There can be no white-space-delimited empty input fields.) It then<br />

generates output for those combined records in which the join key field (the first<br />

field by default) matches in each file. The default output for join is the common join<br />

key field, followed by all the other fields in file1, and then all the other fields in file2.<br />

The other fields from each file appear in the same order they appeared in the<br />

original file. The default output field separator is a space character.<br />

–a n Produces an output line for lines that do not match in addition to one for a<br />

pair of records that does match. If you specify n as one of 1 or 2, join<br />

produces unpaired records from only that file. If you specify both –a 1 and<br />

–a 2, it produces unpaired records from both files.<br />

–e string<br />

Replaces an empty field with string on output. In a doublebyte locale, string<br />

can contain doublebyte characters.<br />

–j[n] m<br />

Uses field number m as the join key field. By default, the join key field is<br />

the first field in each input line. As with the –a option, if n is present, this<br />

option specifies the key field just for that file; otherwise, it specifies it for<br />

both files.<br />

–o list Specifies the fields to be output. You can specify each element in list as<br />

either n.m, where n is a file number (1 or 2) and m is a field number, or as<br />

0 (zero), which represents the join field. You can specify any number of<br />

output fields by separating them with blanks or commas. The<br />

P<strong>OS</strong>IX-compatible version of this command (first form in the syntax)<br />

requires multiple output fields to be specified as a single argument;<br />

therefore, shell quoting may be necessary. join outputs the fields in the<br />

order you list them.<br />

–t c Sets the field separator to the character c. Each instance of c introduces a<br />

new field, making empty fields possible. In a doublebyte locale, c can be a<br />

doublebyte character.<br />

–v n Suppresses matching lines. If you specify n as one of 1 or 2, join produces<br />

unpaired records from only that file. If you specify both –v 1 and –v 2, it<br />

produces unpaired records from both files. This does not suppress any lines<br />

produced using the –a option.<br />

–1 n Uses the nth field of file1 as the join key field.<br />

–2 n Uses the nth field of file2 as the join key field.<br />

1. The following script produces a report about files in the working directory<br />

containing filename, file mode, and an estimate at what the file contains:<br />

file * | tr –s ':' ';' >temp1<br />

ls –l | tr –s ' ' ' ';' >temp2<br />

join –t';' –j2 9 –o 1.1 2.1 1.2 ---<br />

temp1 temp2<br />

rm temp[12]<br />

2. This example uses the historical implementation of the join command. The third<br />

line in the P<strong>OS</strong>IX-compatible script could be:<br />

join –t';' –2 9 –o 1.1,2.1,1.2 -- temp1 temp2<br />

join<br />

Chapter 2. Shell command descriptions 329

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

Saved successfully!

Ooh no, something went wrong!