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