'\" te .\" Copyright 1989 AT&T .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" 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 http://www.opengroup.org/bookstore/. .\" 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. This notice shall appear on any product containing this material. .TH join 1 "7 May 2012" "SunOS 5.11" "User Commands" .SH NAME join \- relational database operator .SH SYNOPSIS .LP .nf \fB/usr/bin/join\fR [\fB-a\fR \fIfilenumber\fR] [\fB-v\fR \fIfilenumber\fR] [\fB-1\fR \fIfieldnumber\fR] [\fB-2\fR \fIfieldnumber\fR] [\fB-o\fR \fIlist\fR] [\fB-e\fR \fIstring\fR][\fB-t\fR \fIchar\fR] \fIfile1\fR \fIfile2\fR .fi .LP .nf \fB/usr/bin/join\fR [\fB-a\fR \fIfilenumber\fR] [\fB-j\fR \fIfieldumber\fR] [\fB-j1\fR \fIfieldnumber\fR] [\fB-j2\fR \fIfieldnumber\fR] [\fB-o\fR \fIlist\fR] [\fB-e\fR \fIstring\fR][\fB-t\fR \fIchar\fR] \fIfile1\fR \fIfile2\fR .fi .SH DESCRIPTION .sp .LP \fBjoin\fR performs an equality join on the files \fIfile1\fR and \fIfile2\fR and writes the resulting joined files to standard output. By default, a field is delimited by one or more spaces and tabs with leading spaces and/or tabs ignored. The \fB-t\fR option can be used to change the field delimiter. .sp .LP The \fBjoin\fR field is a field in each file on which files are compared. By default join writes one line in the output for each pair of lines in \fIfiles1\fR and \fIfiles2\fR that have identical join fields. The default output line consists of the join field, then the remaining fields from \fIfile1\fR, then the remaining fields from \fIfile2\fR, but this can be changed with the \fB-o\fR option. The \fB-a\fR option can be used to add unmatched lines to the output. The \fB-v\fR option can be used to output only unmatched lines. .sp .LP The files \fIfile1\fR and \fIfile2\fR must be ordered in the collating sequence of sort \fB-b\fR on the fields on which they are to be joined otherwise the results are unspecified. .sp .LP If either \fIfile1\fR or \fIfile2\fR is \fB-\fR, join uses standard input starting at the current location. .SH OPTIONS .sp .LP Some of the options below use the argument \fIfilenumber\fR. This argument should be a \fB1\fR or a \fB2\fR referring to either \fIfile1\fR or \fIfile2\fR, respectively. .sp .ne 2 .mk .na \fB\fB-a\fR \fIfilenumber\fR\fR .ad .RS 19n .rt In addition to the normal output, produce a line for each unpairable line in file \fIfilenumber\fR, where \fIfilenumber\fR is \fB1\fR or \fB2\fR. If both \fB-a 1\fR and \fB-a 2\fR are specified, all unpairable lines are output. .RE .sp .ne 2 .mk .na \fB\fB-e\fR \fIstring\fR\fR .ad .RS 19n .rt Replace empty output fields in the list selected by option \fB-o\fR with the string \fIstring\fR. .RE .sp .ne 2 .mk .na \fB\fB-j\fR \fIfieldnumber\fR\fR .ad .RS 19n .rt Equivalent to \fB-1\fR \fIfieldnumber\fR \fB-2\fR\fIfieldnumber\fR. Fields are numbered starting with \fB1\fR. .RE .sp .ne 2 .mk .na \fB\fB-j1\fR \fIfieldnumber\fR\fR .ad .RS 19n .rt Equivalent to \fB-1\fR \fIfieldnumber\fR. Fields are numbered starting with \fB1\fR. .RE .sp .ne 2 .mk .na \fB\fB-j2\fR \fIfieldnumber\fR\fR .ad .RS 19n .rt Equivalent to \fB-2\fR \fIfieldnumber\fR. Fields are numbered starting with \fB1\fR. .RE .sp .ne 2 .mk .na \fB\fB-o\fR \fIlist\fR\fR .ad .RS 19n .rt Each output line includes the fields specified in list. Fields selected by list that do not appear in the input are treated as empty output fields. (See the \fB-e\fR option.) Each element of which has the either the form \fIfilenumber\fR.\fIfieldnumber\fR, or \fB0\fR, which represents the \fBjoin\fR field. The common field is not printed unless specifically requested. .RE .sp .ne 2 .mk .na \fB\fB-t\fR \fIchar\fR\fR .ad .RS 19n .rt Use character char as a separator. Every appearance of \fIchar\fR in a line is significant. The character \fIchar\fR is used as the field separator for both input and output. With this option specified, the collating term should be the same as sort without the \fB-b\fR option. .RE .sp .ne 2 .mk .na \fB\fB-v\fR \fIfilenumber\fR\fR .ad .RS 19n .rt Instead of the default output, produce a line only for each unpairable line in \fIfilenumber\fR, where \fIfilenumber\fR is \fB1\fR or \fB2\fR. If both \fB-v 1\fR and \fB-v 2\fR are specified, all unpairable lines are output. .RE .sp .ne 2 .mk .na \fB\fB-1\fR \fIfieldnumber\fR\fR .ad .RS 19n .rt Join on the \fIfieldnumber\fR-th field of file \fB1\fR. Fields are decimal integers starting with \fB1\fR. .RE .sp .ne 2 .mk .na \fB\fB-2\fR \fIfieldnumber\fR\fR .ad .RS 19n .rt Join on the \fIfieldnumber\fR-th field of file \fB2\fR. Fields are decimal integers starting with \fB1\fR. .RE .SH OPERANDS .sp .LP The following operands are supported: .sp .ne 2 .mk .na \fB\fIfile1\fR\fR .ad .RS 9n .rt A path name of a file to be joined. If either of the \fIfile1\fR or \fIfile2\fR operands is \fB\(mi\fR, the standard input is used in its place. .RE .sp .ne 2 .mk .na \fB\fIfile2\fR\fR .ad .RS 9n .rt A path name of a file to be joined. If either of the \fIfile1\fR or \fIfile2\fR operands is \fB\(mi\fR, the standard input is used in its place. .RE .sp .LP \fIfile1\fR and \fIfile2\fR must be sorted in increasing collating sequence as determined by \fBLC_COLLATE\fR on the fields on which they are to be joined, normally the first in each line (see \fBsort\fR(1)). .SH USAGE .sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBjoin\fR when encountering files greater than or equal to 2 Gbyte (2^31 bytes). .SH EXAMPLES .LP \fBExample 1 \fRJoining the \fBpassword\fR File and Group File .sp .LP The following command line joins the password file and the group file, matching on the numeric group ID, and outputting the login name, the group name and the login directory. It is assumed that the files have been sorted in \fBASCII\fR collating sequence on the group ID fields. .sp .in +2 .nf example% \fBjoin -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group\fR .fi .in -2 .sp .LP \fBExample 2 \fRUsing the \fB-o\fR Option .sp .LP The \fB-o\fR \fB0\fR field essentially selects the union of the join fields. For example, given file \fBphone\fR: .sp .in +2 .nf !Name Phone Number Don +1 123-456-7890 Hal +1 234-567-8901 Yasushi +2 345-678-9012 .fi .in -2 .sp .sp .LP and file \fBfax\fR: .sp .in +2 .nf !Name Fax Number Don +1 123-456-7899 Keith +1 456-789-0122 Yasushi +2 345-678-9011 .fi .in -2 .sp .sp .LP where the large expanses of white space are meant to each represent a single tab character), the command: .sp .in +2 .nf example% \fBjoin -t"\fItab\fR" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax\fR .fi .in -2 .sp .sp .LP would produce .sp .in +2 .nf !Name Phone Number Fax Number Don +1 123-456-7890 +1 123-456-7899 Hal +1 234-567-8901 (unknown Keith (unknown) +1 456-789-012 Yasushi +2 345-678-9012 +2 345-678-9011 .fi .in -2 .sp .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBjoin\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_COLLATE\fR, and \fBNLSPATH\fR. .SH EXIT STATUS .sp .LP The following exit values are returned: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt All input files were output successfully. .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt An error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/core-os _ CSIEnabled _ Interface StabilityCommitted _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBawk\fR(1), \fBcomm\fR(1), \fBsort\fR(1), \fBuniq\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5) .SH NOTES .sp .LP With default field separation, the collating sequence is that of \fBsort\fR \fB-\fR\fBb\fR; with \fB-t\fR, the sequence is that of a plain sort. .sp .LP The conventions of the \fBjoin\fR, \fBsort\fR, \fBcomm\fR, \fBuniq\fR, and \fBawk\fR commands are wildly incongruous.