version 1.5, 1998/09/26 19:54:55 |
version 1.6, 1999/07/04 11:53:55 |
|
|
.Ar file1 |
.Ar file1 |
.Ar file2 |
.Ar file2 |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The join utility performs an ``equality join'' on the specified files |
The |
|
.Nm |
|
utility performs an |
|
.Dq equality join |
|
on the specified files |
and writes the result to the standard output. |
and writes the result to the standard output. |
The ``join field'' is the field in each file by which the files are compared. |
The |
|
.Dq join field |
|
is the field in each file by which the files are compared. |
The first field in each line is used by default. |
The first field in each line is used by default. |
There is one line in the output for each pair of lines in |
There is one line in the output for each pair of lines in |
.Ar file1 |
.Ar file1 |
|
|
The default output field separator is a single space character. |
The default output field separator is a single space character. |
.Pp |
.Pp |
Many of the options use file and field numbers. |
Many of the options use file and field numbers. |
Both file numbers and field numbers are 1 based, i.e. the first file on |
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 command line is file number 1 and the first field is field number 1. |
The following options are available: |
The following options are available: |
.Bl -tag -width Fl |
.Bl -tag -width Fl |
|
|
is a file number and |
is a file number and |
.Ar field |
.Ar field |
is a field number. |
is a field number. |
The elements of list must be either comma (``,'') or whitespace separated. |
The elements of list must be either comma |
|
.Pq Ql \&, |
|
or whitespace separated. |
(The latter requires quoting to protect it from the shell, or, a simpler |
(The latter requires quoting to protect it from the shell, or, a simpler |
approach is to use multiple |
approach is to use multiple |
.Fl o |
.Fl o |
|
|
using the |
using the |
.Fl b |
.Fl b |
option, on the fields on which they are to be joined, otherwise |
option, on the fields on which they are to be joined, otherwise |
.Nm join |
.Nm |
may not report all field matches. |
may not report all field matches. |
When the field delimiter characters are specified by the |
When the field delimiter characters are specified by the |
.Fl t |
.Fl t |
|
|
.Ar file1 |
.Ar file1 |
or |
or |
.Ar file2 |
.Ar file2 |
is ``-'', the standard input is used. |
is |
|
.Ql \&- , |
|
the standard input is used. |
.Pp |
.Pp |
The |
The |
.Nm join |
.Nm |
utility exits 0 on success or >0 if an error occurred. |
utility exits 0 on success or >0 if an error occurred. |
.Sh COMPATIBILITY |
.Sh COMPATIBILITY |
For compatibility with historic versions of |
For compatibility with historic versions of |
|
|
in both file 1 and file 2. |
in both file 1 and file 2. |
(To distinguish between this and |
(To distinguish between this and |
.Fl a Ar file_number , |
.Fl a Ar file_number , |
.Nm join |
.Nm |
currently requires that the latter not include any white space.) |
currently requires that the latter not include any white space.) |
.It Fl j1 Ar field |
.It Fl j1 Ar field |
Join on the |
Join on the |
|
|
field of both file 1 and file 2. |
field of both file 1 and file 2. |
.It Fl o Ar list ... |
.It Fl o Ar list ... |
Historical implementations of |
Historical implementations of |
.Nm join |
.Nm |
permitted multiple arguments to the |
permitted multiple arguments to the |
.Fl o |
.Fl o |
option. |
option. |
These arguments were of the form ``file_number.field_number'' as described |
These arguments were of the form |
for the current |
.Dq file_number.field_number |
|
as described for the current |
.Fl o |
.Fl o |
option. |
option. |
This has obvious difficulties in the presence of files named ``1.2''. |
This has obvious difficulties in the presence of files named |
|
.Dq 1.2 . |
.El |
.El |
.Pp |
.Pp |
These options are available only so historic shell scripts don't require |
These options are available only so historic shell scripts don't require |
modification and should not be used. |
modification and should not be used. |
.Sh STANDARDS |
.Sh STANDARDS |
The |
The |
.Nm join |
.Nm |
command is expected to be |
command is expected to be |
.St -p1003.2 |
.St -p1003.2 |
compatible. |
compatible. |