Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

join(1) OSS Shell and Utilities Reference Manual
If phonedir contains:
Binst 555-6235
Dickerson 555-1842
Eisner 555-1234
Green 555-2240
Hrarii 555-0256
Janatha 555-7358
Lewis 555-3237
Takata 555-5341
Wozni 555-1234
and names contains:
Eisner Dept. 389
Frost Dept. 217
Green Dept. 311
Takata Dept. 454
Wozni Dept. 520
then join -o 2.3,2.1,1.2 phonedir names displays:
389 Eisner 555-1234
311 Green 555-2240
454 Takata 555-5341
520 Wozni 555-1234
4. To perform a join operation on a eld other than the rst eld, enter:
sort -b +1 -2 phonedir | join -1 2 - numbers
This command combines the lines in phonedir and names, comparing the second eld of
phonedir to the rst eld of numbers.
First, this command sorts phonedir by the second eld, because both les must be sorted
by the join eld. The output of sort is then piped to join. The - (dash) by itself causes
the join command to use this sorted output as its le1. -1 2 denes the second eld of the
sorted phonedir as the join eld. This eld is compared to the rst eld of numbers (its
join eld is not specied with a -2 ag).
If phonedir contains:
Binst 555-6235
Dickerson 555-1842
Eisner 555-1234
Green 555-2240
Hrarii 555-0256
Janatha 555-7358
Lewis 555-3237
Takata 555-5341
Wozni 555-1234
464 Hewlett-Packard Company 527188-007