join(1)
NAME
join − relational database operator
SYNOPSIS
join [ −an ] [ −e s ] [ −jn m ] [ −o list ] [ −tc ] filename1 filename2
AVAILABILITY
SUNWcsu
DESCRIPTION
join forms, on the standard output, a join of the two relations specified by the lines of filename1 and filename2. If filename1 is − , the standard input is used.
filename1 and filename2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in each line (see sort(1)).
There is one line in the output for each pair of lines in filename1 and filename2 that have identical join fields. The output line normally consists of the common field, then the rest of the line from filename1, then the rest of the line from filename2.
The default input field separators are blank, tab, or new-line. In this case, multiple separators count as one field separator, and leading separators are ignored. The default output field separator is a blank.
OPTIONS
Some of the options below use the argument n. This argument should be a 1 or a 2 referring to either filename1 or filename2, respectively.
−an In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2.
−e s Replace empty output fields with string s.
−jn m Join on the mth field of file n. If n is missing, use the mth field in each file. Fields are numbered starting with 1.
−o list Each output line includes the fields specified in list, each element of which has the form n.m, where n is a file number and m is a field number. The common field is not printed unless specifically requested.
−tc Use character c as a separator (tab character). Every appearance of c in a line is significant. The character c is used as the field separator for both input and output.
EXAMPLES
The following command line will join 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 ASCII collating sequence on the group ID fields.
example% join −j1 4 −j2 3 −o 1.1 2.1 1.6 −t: /etc/passwd /etc/group
ENVIRONMENT
If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of join for each corresponding locale category is determined by the value of the LANG environment variable. If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables. If none of the above variables is set in the environment, the "C" (U.S. style) locale determines how join behaves.
LC_CTYPE
Determines how join handles characters. When LC_CTYPE is set to a valid value, join can display and handle text and filenames containing valid characters for that locale. join can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. join can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid.
LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).
SEE ALSO
awk(1), comm(1), sort(1), uniq(1), environ(5)
NOTES
With default field separation, the collating sequence is that of sort −b; with −t, the sequence is that of a plain sort.
The conventions of the join, sort, comm, uniq, and awk commands are wildly incongruous.
Filenames that are numeric may cause conflict when the −o option is used just before listing filenames.
SunOS 5.1/SPARC — Last change: 14 Sep 1992