Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
join(1) OSS Shell and Utilities Reference Manual
NAME
join - Joins the lines of two files
SYNOPSIS
Current syntax
join [-a filenum_a]
[-e string]
[-o number.field, ... ]
[-t character]
[-v filenum_v]
[-1 field1][-2 field2]
file1 file2
Obsolescent syntax
join [-a filenum_a]
[-e string]
[-j num | field | num fld]
[-o number.field, ...]
[-t character]
file1 file2
FLAGS
-1 field1 Specifies the number of the join field for file1. field1 is a decimal integer starting with
1.
-2 field2 Specifies the number of the join field for file2. field2 is a decimal integer starting with
1.
-a filenum_a
Produces an output line for each unmatched line found in file1 if filenum_a is 1 or in
file2 if number is 2. Without -a, join produces output only for lines containing a
matching field. If both -a 1 and -a 2 are used, the output contains all unmatched lines.
-e string Replaces empty output fields with string.
-j num | fld | num fld
(Obsolescent) Specifies the join field fld for file num, where num is 1 for file1 or 2 for
file2. If you do not specify num, join uses fld in both files. Without -j, join uses the
first field in each file. The default value for both num and fld is 1.
If you enter only a 1 or a 2 as an argument to -j, join interprets this argument as the file
number (num); integers greater than 2 are interpreted as the field number (fld). There-
fore, if you want to specify a field number of 1 or 2, you must precede the fld
specification with a num argument; otherwise, the join command interprets the 1 or 2
as the file number (num).
-o number.field
Produces output lines consisting of the fields given by one or more number.field argu-
ments in the specified order, where number is 1 for file1 or 2 for file2 and field is a field
number. Multiple -o arguments should be separated with commas.
-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,
4−58 Hewlett-Packard Company 527188-003