Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (g - j) join(1)
then join phonedir names displays:
Eisner 555-1234 Dept. 389
Green 555-2240 Dept. 311
Takata 555-5341 Dept. 454
Wozni 555-1234 Dept. 520
Each line consists of the join field found in both files (the last name), followed by the rest
of the line found in phonedir, followed by the rest of the line found in names.
2. To display unmatched lines in names as well as matched lines in both files, enter:
join -a 2 phonedir names
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 -a 2 phonedir names displays:
Eisner 555-1234 Dept. 389
Frost Dept. 217
Green 555-2240 Dept. 311
Takata 555-5341 Dept. 454
Wozni 555-1234 Dept. 520
This command performs the same join operation as in the first example and also lists the
lines of names that have no match in phonedir (the entry for Frost).
3. To perform a join operation and display selected fields, enter:
join -o 2.3,2.1,1.2 phonedir names
This command displays the following fields in this order:
Field 3 of names (department number without "Dept.")
Field 1 of names (last name)
Field 2 of phonedir (telephone number)
527188-007 Hewlett-Packard Company 4−63