BSD 4_4_Lite2 development
[unix-history] / usr / share / man / cat1 / join.0
JOIN(1) BSD Reference Manual JOIN(1)
N\bNA\bAM\bME\bE
j\bjo\boi\bin\bn - relational database operator
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
j\bjo\boi\bin\bn [-\b-a\ba _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br | -\b-v\bv _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br] [-\b-e\be _\bs_\bt_\br_\bi_\bn_\bg] [-\b-j\bj _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br _\bf_\bi_\be_\bl_\bd]
[-\b-o\bo _\bl_\bi_\bs_\bt] [-\b-t\bt _\bc_\bh_\ba_\br] [-\b-1\b1 _\bf_\bi_\be_\bl_\bd] [-\b-2\b2 _\bf_\bi_\be_\bl_\bd] _\bf_\bi_\bl_\be_\b1 _\bf_\bi_\bl_\be_\b2
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
The join utility performs an ``equality join'' on the specified files and
writes the result to the standard output. The ``join field'' is the
field in each file by which the files are compared. The first field in
each line is used by default. There is one line in the output for each
pair of lines in _\bf_\bi_\bl_\be_\b1 and _\bf_\bi_\bl_\be_\b2 which have identical join fields. Each
output line consists of the join field, the remaining fields from _\bf_\bi_\bl_\be_\b1
and then the remaining fields from _\bf_\bi_\bl_\be_\b2.
The default field separators are tab and space characters. In this case,
multiple tabs and spaces count as a single field separator, and leading
tabs and spaces are ignored. The default output field separator is a
single space character.
Many of the options use file and field numbers. Both file numbers and
field numbers are 1 based, i.e. the first file on the command line is
file number 1 and the first field is field number 1. The following op-
tions are available:
-\b-a\ba _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br
In addition to the default output, produce a line for each
unpairable line in file _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br. (The argument to -\b-a\ba must
not be preceded by a space; see the _\bC_\bO_\bM_\bP_\bA_\bT_\bI_\bB_\bI_\bL_\bI_\bT_\bY section.)
-\b-e\be _\bs_\bt_\br_\bi_\bn_\bg Replace empty output fields with _\bs_\bt_\br_\bi_\bn_\bg.
-\b-o\bo _\bl_\bi_\bs_\bt The -\b-o\bo option specifies the fields that will be output from
each file for each line with matching join fields. Each ele-
ment of _\bl_\bi_\bs_\bt has the form `file_number.field', where
_\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br is a file number and _\bf_\bi_\be_\bl_\bd is a field number.
The elements of list must be either comma (``,'') or whites-
pace separated. (The latter requires quoting to protect it
from the shell, or, a simpler approach is to use multiple -\b-o\bo
options.)
-\b-t\bt _\bc_\bh_\ba_\br Use character _\bc_\bh_\ba_\br as a field delimiter for both input and
output. Every occurrence of _\bc_\bh_\ba_\br in a line is significant.
-\b-v\bv _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br
Do not display the default output, but display a line for
each unpairable line in file _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br. The options -\b-v\bv _\b1
and -\b-v\bv _\b2 may be specified at the same time.
-\b-1\b1 _\bf_\bi_\be_\bl_\bd Join on the _\bf_\bi_\be_\bl_\bd'th field of file 1.
-\b-2\b2 _\bf_\bi_\be_\bl_\bd Join on the _\bf_\bi_\be_\bl_\bd'th field of file 2.
When the default field delimiter characters are used, the files to be
joined should be ordered in the collating sequence of sort(1), using the
-\b-b\bb option, on the fields on which they are to be joined, otherwise j\bjo\boi\bin\bn
may not report all field matches. When the field delimiter characters
are specified by the -\b-t\bt option, the collating sequence should be the same
as sort without the -\b-b\bb option.
If one of the arguments _\bf_\bi_\bl_\be_\b1 or _\bf_\bi_\bl_\be_\b2 is ``-'', the standard input is
used.
The j\bjo\boi\bin\bn utility exits 0 on success, and >0 if an error occurs.
C\bCO\bOM\bMP\bPA\bAT\bTI\bIB\bBI\bIL\bLI\bIT\bTY\bY
For compatibility with historic versions of j\bjo\boi\bin\bn, the following options
are available:
-\b-a\ba In addition to the default output, produce a line for each
unpairable line in both file 1 and file 2. (To distinguish
between this and -\b-a\ba _\bf_\bi_\bl_\be_\b__\bn_\bu_\bm_\bb_\be_\br, j\bjo\boi\bin\bn currently requires that
the latter not include any white space.)
-\b-j\bj1\b1 _\bf_\bi_\be_\bl_\bd Join on the _\bf_\bi_\be_\bl_\bd'th field of file 1.
-\b-j\bj2\b2 _\bf_\bi_\be_\bl_\bd Join on the _\bf_\bi_\be_\bl_\bd'th field of file 2.
-\b-j\bj _\bf_\bi_\be_\bl_\bd Join on the _\bf_\bi_\be_\bl_\bd'th field of both file 1 and file 2.
-\b-o\bo _\bl_\bi_\bs_\bt _\b._\b._\b.
Historical implementations of j\bjo\boi\bin\bn permitted multiple argu-
ments to the -\b-o\bo option. These arguments were of the form
``file_number.field_number'' as described for the current -\b-o\bo
option. This has obvious difficulties in the presence of
files named ``1.2''.
These options are available only so historic shellscripts don't require
modification and should not be used.
S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
The j\bjo\boi\bin\bn command is expected to be IEEE Std1003.2 (``POSIX'') compatible.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
awk(1), comm(1), paste(1), sort(1), uniq(1)
4.4BSD April 28, 1995 2