Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
User Commands (g - j) join(1)
-t character
Uses character (a single character) as the field separator character in
the input and the output. Every appearance of character in a line is
significant. The default separator is a space. If you do not specify -t,
join also recognizes the tab and newline characters as separators.
With default field separation, the collating sequence is that of sort -b.
If you specify -t, the sequence is that of a plain sort. To specify a tab
character, enclose it in ’’(single quotes).
-v filenum_v
Produces an output line for each unmatched line in filenum_v (where
filenum_v is 1 for file1 or 2 for file2), instead of the default output. If
both -v 1 and -v 2 are specified, join produces output lines for all
unmatched lines.
DESCRIPTION
The join command reads file1 and file2, joins the lines in those files that contain common fields
or otherwise according to the flags, and writes the results to the standard output file.
The join field is the field in the input files that join searches to determine what will be included in
the output. One line appears in the output for each identical join field appearing in both file1 and
file2. The output line consists of the join field, the rest of the line from file1, then the rest of the
line from file2.
You can specify the standard input file in place of file1 or file2 by substituting a - (dash) for the
operand.
Both input files must be sorted according to the collating sequence specified by the
LC_COLLATE environment variable, if set, for the fields on which they are to be compared (by
default, the first field in each line).
Fields are normally separated by a space, a tab character, or a newline character. join treats con-
secutive occurrences of these separators as a single separator and discards leading separators.
Use the -t flag to specify another field separator.
Environment Variables
This command supports the use of the LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
LC_MESSAGES, and NLSPATH environment variables.
EXAMPLES
Note that the vertical alignment shown in these examples might not be consistent with your out-
put.
1. To perform a simple join operation on two files, phonedir and names,
whose first fields contain employee last names, enter:
join phonedir names
If phonedir contains the following telephone directory:
Binst 555-6235
Dickerson 555-1842
Eisner 555-1234
Green 555-2240
Hrarii 555-0256
Janatha 555-7358
Lewis 555-3237
Takata 555-5341
527188-021 Hewlett-Packard Company 4−67