Annotation of src/usr.bin/join/join.1, Revision 1.5
1.3 michaels 1: .\" Copyright (c) 1990, 1993
2: .\" The Regents of the University of California. All rights reserved.
1.1 deraadt 3: .\"
4: .\" This code is derived from software contributed to Berkeley by
5: .\" the Institute of Electrical and Electronics Engineers, Inc.
6: .\"
7: .\" Redistribution and use in source and binary forms, with or without
8: .\" modification, are permitted provided that the following conditions
9: .\" are met:
10: .\" 1. Redistributions of source code must retain the above copyright
11: .\" notice, this list of conditions and the following disclaimer.
12: .\" 2. Redistributions in binary form must reproduce the above copyright
13: .\" notice, this list of conditions and the following disclaimer in the
14: .\" documentation and/or other materials provided with the distribution.
15: .\" 3. All advertising materials mentioning features or use of this software
16: .\" must display the following acknowledgement:
17: .\" This product includes software developed by the University of
18: .\" California, Berkeley and its contributors.
19: .\" 4. Neither the name of the University nor the names of its contributors
20: .\" may be used to endorse or promote products derived from this software
21: .\" without specific prior written permission.
22: .\"
23: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: .\" SUCH DAMAGE.
34: .\"
1.3 michaels 35: .\" @(#)join.1 8.3 (Berkeley) 4/28/95
1.1 deraadt 36: .\"
1.3 michaels 37: .Dd April 28, 1995
1.1 deraadt 38: .Dt JOIN 1
39: .Os
40: .Sh NAME
41: .Nm join
42: .Nd relational database operator
43: .Sh SYNOPSIS
44: .Nm join
45: .Oo
46: .Fl a Ar file_number | Fl v Ar file_number
47: .Oc
48: .Op Fl e Ar string
49: .Op Fl j Ar file_number field
50: .Op Fl o Ar list
51: .Bk -words
52: .Ek
53: .Op Fl t Ar char
54: .Op Fl \&1 Ar field
55: .Op Fl \&2 Ar field
56: .Ar file1
57: .Ar file2
58: .Sh DESCRIPTION
59: The join utility performs an ``equality join'' on the specified files
60: and writes the result to the standard output.
61: The ``join field'' is the field in each file by which the files are compared.
62: The first field in each line is used by default.
63: There is one line in the output for each pair of lines in
64: .Ar file1
65: and
66: .Ar file2
67: which have identical join fields.
1.4 millert 68: Each output line consists of the join field, the remaining fields from
1.1 deraadt 69: .Ar file1
1.4 millert 70: and then the remaining fields from
1.1 deraadt 71: .Ar file2 .
72: .Pp
73: The default field separators are tab and space characters.
74: In this case, multiple tabs and spaces count as a single field separator,
75: and leading tabs and spaces are ignored.
76: The default output field separator is a single space character.
77: .Pp
78: Many of the options use file and field numbers.
79: Both file numbers and field numbers are 1 based, i.e. the first file on
80: the command line is file number 1 and the first field is field number 1.
81: The following options are available:
82: .Bl -tag -width Fl
83: .It Fl a Ar file_number
84: In addition to the default output, produce a line for each unpairable
85: line in file
86: .Ar file_number .
1.3 michaels 87: (The argument to
88: .Fl a
89: must not be preceded by a space; see the
90: .Sx COMPATIBILITY
91: section.)
1.1 deraadt 92: .It Fl e Ar string
93: Replace empty output fields with
94: .Ar string .
95: .It Fl o Ar list
1.5 ! aaron 96: Specifies the fields that will be output from each file for
1.1 deraadt 97: each line with matching join fields.
98: Each element of
99: .Ar list
100: has the form
101: .Ql file_number.field ,
102: where
103: .Ar file_number
104: is a file number and
105: .Ar field
106: is a field number.
107: The elements of list must be either comma (``,'') or whitespace separated.
1.3 michaels 108: (The latter requires quoting to protect it from the shell, or, a simpler
1.1 deraadt 109: approach is to use multiple
110: .Fl o
111: options.)
112: .It Fl t Ar char
113: Use character
114: .Ar char
115: as a field delimiter for both input and output.
116: Every occurrence of
117: .Ar char
118: in a line is significant.
119: .It Fl v Ar file_number
120: Do not display the default output, but display a line for each unpairable
121: line in file
122: .Ar file_number .
123: The options
124: .Fl v Ar 1
125: and
126: .Fl v Ar 2
127: may be specified at the same time.
128: .It Fl 1 Ar field
129: Join on the
130: .Ar field Ns 'th
131: field of file 1.
132: .It Fl 2 Ar field
133: Join on the
134: .Ar field Ns 'th
135: field of file 2.
136: .El
137: .Pp
138: When the default field delimiter characters are used, the files to be joined
139: should be ordered in the collating sequence of
140: .Xr sort 1 ,
141: using the
142: .Fl b
143: option, on the fields on which they are to be joined, otherwise
144: .Nm join
145: may not report all field matches.
146: When the field delimiter characters are specified by the
147: .Fl t
148: option, the collating sequence should be the same as
149: .Xr sort
150: without the
151: .Fl b
152: option.
153: .Pp
154: If one of the arguments
155: .Ar file1
156: or
157: .Ar file2
158: is ``-'', the standard input is used.
159: .Pp
160: The
161: .Nm join
1.5 ! aaron 162: utility exits 0 on success or >0 if an error occurred.
1.1 deraadt 163: .Sh COMPATIBILITY
164: For compatibility with historic versions of
165: .Nm join ,
166: the following options are available:
167: .Bl -tag -width Fl
168: .It Fl a
169: In addition to the default output, produce a line for each unpairable line
170: in both file 1 and file 2.
1.3 michaels 171: (To distinguish between this and
172: .Fl a Ar file_number ,
173: .Nm join
174: currently requires that the latter not include any white space.)
1.1 deraadt 175: .It Fl j1 Ar field
176: Join on the
177: .Ar field Ns 'th
178: field of file 1.
179: .It Fl j2 Ar field
180: Join on the
181: .Ar field Ns 'th
182: field of file 2.
183: .It Fl j Ar field
184: Join on the
185: .Ar field Ns 'th
186: field of both file 1 and file 2.
187: .It Fl o Ar list ...
188: Historical implementations of
189: .Nm join
190: permitted multiple arguments to the
191: .Fl o
192: option.
193: These arguments were of the form ``file_number.field_number'' as described
194: for the current
195: .Fl o
196: option.
197: This has obvious difficulties in the presence of files named ``1.2''.
198: .El
199: .Pp
1.5 ! aaron 200: These options are available only so historic shell scripts don't require
1.1 deraadt 201: modification and should not be used.
202: .Sh STANDARDS
203: The
204: .Nm join
205: command is expected to be
206: .St -p1003.2
207: compatible.
208: .Sh SEE ALSO
209: .Xr awk 1 ,
210: .Xr comm 1 ,
211: .Xr paste 1 ,
212: .Xr sort 1 ,
213: .Xr uniq 1