Annotation of src/usr.bin/join/join.1, Revision 1.14
1.14 ! otto 1: .\" $OpenBSD: join.1,v 1.13 2003/06/10 09:12:10 jmc 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 .
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
1.9 aaron 101: .Dq file_number.field ,
1.1 deraadt 102: where
103: .Ar file_number
104: is a file number and
105: .Ar field
1.14 ! otto 106: is a field number,
! 107: or the form
! 108: .Dq 0
! 109: (zero),
! 110: representing the join field.
1.6 aaron 111: The elements of list must be either comma
112: .Pq Ql \&,
113: or whitespace separated.
1.3 michaels 114: (The latter requires quoting to protect it from the shell, or, a simpler
1.1 deraadt 115: approach is to use multiple
116: .Fl o
117: options.)
118: .It Fl t Ar char
119: Use character
120: .Ar char
121: as a field delimiter for both input and output.
122: Every occurrence of
123: .Ar char
124: in a line is significant.
125: .It Fl v Ar file_number
126: Do not display the default output, but display a line for each unpairable
127: line in file
128: .Ar file_number .
129: The options
130: .Fl v Ar 1
131: and
132: .Fl v Ar 2
133: may be specified at the same time.
134: .It Fl 1 Ar field
135: Join on the
136: .Ar field Ns 'th
137: field of file 1.
138: .It Fl 2 Ar field
139: Join on the
140: .Ar field Ns 'th
141: field of file 2.
142: .El
143: .Pp
144: When the default field delimiter characters are used, the files to be joined
145: should be ordered in the collating sequence of
146: .Xr sort 1 ,
147: using the
148: .Fl b
149: option, on the fields on which they are to be joined, otherwise
1.6 aaron 150: .Nm
1.1 deraadt 151: may not report all field matches.
152: When the field delimiter characters are specified by the
153: .Fl t
154: option, the collating sequence should be the same as
1.13 jmc 155: .Xr sort 1
1.1 deraadt 156: without the
157: .Fl b
158: option.
159: .Pp
160: If one of the arguments
161: .Ar file1
162: or
163: .Ar file2
1.6 aaron 164: is
1.9 aaron 165: .Dq - ,
1.6 aaron 166: the standard input is used.
1.9 aaron 167: .\" XXX - use .br as a work-around for an apparent bug in mdoc
168: .br
1.1 deraadt 169: .Pp
170: The
1.6 aaron 171: .Nm
1.5 aaron 172: utility exits 0 on success or >0 if an error occurred.
1.11 aaron 173: .Sh SEE ALSO
174: .Xr awk 1 ,
175: .Xr comm 1 ,
176: .Xr paste 1 ,
177: .Xr sort 1 ,
178: .Xr uniq 1
1.13 jmc 179: .Sh STANDARDS
1.1 deraadt 180: For compatibility with historic versions of
181: .Nm join ,
182: the following options are available:
183: .Bl -tag -width Fl
184: .It Fl a
185: In addition to the default output, produce a line for each unpairable line
186: in both file 1 and file 2.
187: .It Fl j1 Ar field
188: Join on the
189: .Ar field Ns 'th
190: field of file 1.
191: .It Fl j2 Ar field
192: Join on the
193: .Ar field Ns 'th
194: field of file 2.
195: .It Fl j Ar field
196: Join on the
197: .Ar field Ns 'th
198: field of both file 1 and file 2.
199: .It Fl o Ar list ...
200: Historical implementations of
1.6 aaron 201: .Nm
1.1 deraadt 202: permitted multiple arguments to the
203: .Fl o
204: option.
1.6 aaron 205: These arguments were of the form
206: .Dq file_number.field_number
207: as described for the current
1.1 deraadt 208: .Fl o
209: option.
1.6 aaron 210: This has obvious difficulties in the presence of files named
211: .Dq 1.2 .
1.1 deraadt 212: .El
213: .Pp
1.5 aaron 214: These options are available only so historic shell scripts don't require
1.1 deraadt 215: modification and should not be used.
1.13 jmc 216: .Pp
1.1 deraadt 217: The
1.6 aaron 218: .Nm
1.1 deraadt 219: command is expected to be
220: .St -p1003.2
221: compatible.