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