386BSD 0.1 development
[unix-history] / usr / src / usr.bin / join / join.1
CommitLineData
5824a9c7
WJ
1.TH JOIN 1L \" -*- nroff -*-
2.SH NAME
3join \- join lines of two files on a common field
4.SH SYNOPSIS
5.B join
6[\-a 1|2] [\-v 1|2] [\-e empty-string] [\-o field-list...] [\-t char]
7[\-j[1|2] field] [\-1 field] [\-2 field] file1 file2
8.SH DESCRIPTION
9This manual page
10documents the GNU version of
11.BR join .
12.B join
13prints to the standard output a line for each pair of input lines, one
14each from
15.I file1
16and
17.IR file2 ,
18that have identical join fields. Either filename (but not both) can
19be `\-', meaning the standard input.
20.I file1
21and
22.I file2
23should be already sorted in increasing order (not numerically) on the
24join fields; unless the
25.I \-t
26option is given, they should be sorted ignoring blanks at the start of
27the line, as
28.B sort
29does when given the
30.I \-b
31option.
32.PP
33The defaults are: the join field is the first field in each line;
34fields in the input are separated by one or more blanks, with leading
35blanks on the line ignored; fields in the output are separated by a
36space; each output line consists of the join field, the remaining
37fields from
38.IR file1 ,
39then the remaining fields from
40.IR file2 .
41.SS OPTIONS
42.TP
43.I "\-a file-number"
44Print a line for each unpairable line in file
45.I file-number
46(either 1 or 2), in addition to the normal output.
47.TP
48.I "\-e string"
49Replace empty output fields (those that are missing in the input) with
50.IR string .
51.TP
52.I "\-1, \-j1 field"
53Join on field
54.I field
55(a positive integer) of file 1.
56.TP
57.I "\-2, \-j2 field"
58Join on field
59.I field
60(a positive integer) of file 2.
61.TP
62.I "\-j field"
63Equivalent to
64.IR "\-1 field \-2 field" .
65.TP
66.I "\-o field-list..."
67Construct each output line according to the format in
68.IR field-list .
69Each element in
70.I field-list
71consists of a file number (either 1 or 2), a period, and a field
72number (a positive integer). The elements in the list are separated
73by commas or blanks. Multiple
74.I field-list
75arguments can be given after a single
76.I \-o
77option; the values of all lists given with
78.I \-o
79are concatenated together.
80.TP
81.I "\-t char"
82Use character
83.I char
84as the input and output field separator.
85.TP
86.I "\-v file-number"
87Print a line for each unpairable line in file
88.I file-number
89(either 1 or 2), instead of the normal output.
90.PP
91The long-named options can be introduced with `+' as well as `\-\-',
92for compatibility with previous releases. Eventually support for `+'
93will be removed, because it is incompatible with the POSIX.2 standard.