2 .\" Copyright 1989 AT&T Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH JOIN 1 "Feb 8, 2000"
12 join \- relational database operator
16 \fBjoin\fR [\fB-a\fR \fIfilenumber\fR | \fB-v\fR \fIfilenumber\fR] [\fB-1\fR \fIfieldnumber\fR]
17 [\fB-2\fR \fIfieldnumber\fR] [\fB-o\fR \fIlist\fR] [\fB-e\fR \fIstring\fR] [\fB-t\fR \fIchar\fR] \fIfile1\fR \fIfile2\fR
22 \fBjoin\fR [\fB-a\fR \fIfilenumber\fR] [\fB-j\fR \fIfieldnumber\fR] [\fB-j1\fR \fIfieldnumber\fR]
23 [\fB-j2\fR \fIfieldnumber\fR] [\fB-o\fR \fIlist\fR] [\fB-e\fR \fIstring\fR] [\fB-t\fR \fIchar\fR] \fIfile1\fR \fIfile2\fR
29 The \fBjoin\fR command forms, on the standard output, a join of the two
30 relations specified by the lines of \fIfile1\fR and \fIfile2\fR.
33 There is one line in the output for each pair of lines in \fIfile1\fR and
34 \fIfile2\fR that have identical join fields. The output line normally consists
35 of the common field, then the rest of the line from \fIfile1\fR, then the rest
36 of the line from \fIfile2\fR. This format can be changed by using the \fB-o\fR
37 option (see below). The \fB-a\fR option can be used to add unmatched lines to
38 the output. The \fB-v\fR option can be used to output only unmatched lines.
41 The default input field separators are blank, tab, or new-line. In this case,
42 multiple separators count as one field separator, and leading separators are
43 ignored. The default output field separator is a blank.
46 If the input files are not in the appropriate collating sequence, the results
51 Some of the options below use the argument \fIfilenumber\fR. This argument
52 should be a \fB1\fR or a \fB2\fR referring to either \fIfile1\fR or
53 \fIfile2\fR, respectively.
57 \fB\fB-a\fR \fIfilenumber\fR \fR
60 In addition to the normal output, produce a line for each unpairable line in
61 file \fIfilenumber\fR, where \fIfilenumber\fR is \fB1\fR or \fB2\fR. If both
62 \fB-a\fR \fB1\fR and \fB-a\fR \fB2\fR are specified, all unpairable lines will
69 \fB\fB-e\fR \fIstring\fR \fR
72 Replace empty output fields in the list selected by option \fB-o\fR with the
79 \fB\fB-j\fR \fIfieldnumber\fR \fR
82 Equivalent to \fB-1\fR\fIfieldnumber\fR \fB-\fR\fB2\fR\fIfieldnumber\fR.
88 \fB\fB-j1\fR \fIfieldnumber\fR \fR
91 Equivalent to \fB-1\fR\fIfieldnumber\fR.
97 \fB\fB-j2\fR \fIfieldnumber\fR \fR
100 Equivalent to \fB-2\fR\fIfieldnumber\fR. Fields are numbered starting with
107 \fB\fB-o\fR \fIlist\fR \fR
110 Each output line includes the fields specified in \fIlist\fR. Fields selected
111 by \fIlist\fR that do not appear in the input will be treated as empty output
112 fields. (See the \fB-e\fR option.) Each element of which has the either the
113 form \fIfilenumber\fR\fB\&.\fR\fIfieldnumber\fR\fB,\fR or \fB0\fR, which
114 represents the \fBjoin\fR field. The common field is not printed unless
115 specifically requested.
121 \fB\fB-t\fR \fIchar\fR \fR
124 Use character \fIchar\fR as a separator. Every appearance of \fIchar\fR in a
125 line is significant. The character \fIchar\fR is used as the field separator
126 for both input and output. With this option specified, the collating term
127 should be the same as \fBsort\fR without the \fB-b\fR option.
133 \fB\fB-v\fR \fIfilenumber\fR \fR
136 Instead of the default output, produce a line only for each unpairable line in
137 \fIfilenumber\fR, where \fIfilenumber\fR is \fB1\fR or \fB2\fR. If both
138 \fB-v\fR \fB1\fR and \fB-v\fR \fB2\fR are specified, all unpairable lines will
145 \fB\fB-1\fR \fIfieldnumber\fR \fR
148 Join on the \fIfieldnumber\fRth field of file 1. Fields are decimal integers
149 starting with \fB1\fR.
155 \fB\fB-2\fR\fIfieldnumber\fR \fR
158 Join on the \fIfieldnumber\fRth field of file 2. Fields are decimal integers
159 starting with \fB1\fR.
165 The following operands are supported:
181 A path name of a file to be joined. If either of the \fIfile1\fR or \fIfile2\fR
182 operands is \fB\(mi\fR, the standard input is used in its place.
187 \fIfile1\fR and \fIfile2\fR must be sorted in increasing collating sequence as
188 determined by \fBLC_COLLATE\fR on the fields on which they are to be joined,
189 normally the first in each line (see \fBsort\fR(1)).
193 See \fBlargefile\fR(5) for the description of the behavior of \fBjoin\fR when
194 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
197 \fBExample 1 \fRJoining the password file and group file
200 The following command line will join the password file and the group file,
201 matching on the numeric group ID, and outputting the login name, the group name
202 and the login directory. It is assumed that the files have been sorted in
203 \fBASCII\fR collating sequence on the group ID fields.
208 example% \fBjoin -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group\fR
214 \fBExample 2 \fRUsing the -o option
217 The \fB-o\fR \fB0\fR field essentially selects the union of the join fields.
218 For example, given file \fBphone\fR:
226 Yasushi +2 345-678-9012
242 Keith +1 456-789-0122
244 Yasushi +2 345-678-9011
251 where the large expanses of white space are meant to each represent a single
252 tab character), the command:
257 example% \fBjoin -t"\fItab\fR" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax\fR
269 !Name Phone Number Fax Number
270 Don +1 123-456-7890 +1 123-456-7899
271 Hal +1 234-567-8901 (unknown
272 Keith (unknown) +1 456-789-012
273 Yasushi +2 345-678-9012 +2 345-678-9011
278 .SH ENVIRONMENT VARIABLES
281 See \fBenviron\fR(5) for descriptions of the following environment variables
282 that affect the execution of \fBjoin\fR: \fBLANG\fR, \fBLC_ALL\fR,
283 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_COLLATE\fR, and \fBNLSPATH\fR.
287 The following exit values are returned:
294 All input files were output successfully.
309 See \fBattributes\fR(5) for descriptions of the following attributes:
317 ATTRIBUTE TYPE ATTRIBUTE VALUE
321 Interface Stability Standard
327 \fBawk\fR(1), \fBcomm\fR(1), \fBsort\fR(1), \fBuniq\fR(1), \fBattributes\fR(5),
328 \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
332 With default field separation, the collating sequence is that of \fBsort\fR
333 \fB-\fR\fBb\fR; with \fB-t\fR, the sequence is that of a plain sort.
336 The conventions of the \fBjoin\fR, \fBsort\fR, \fBcomm\fR, \fBuniq\fR, and
337 \fBawk\fR commands are wildly incongruous.