version 1.16, 2006/05/02 05:21:41 |
version 1.17, 2006/12/28 11:27:41 |
|
|
.Nd relational database operator |
.Nd relational database operator |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm join |
.Nm join |
|
.Op Fl 1 Ar field |
|
.Op Fl 2 Ar field |
.Oo |
.Oo |
.Fl a Ar file_number | Fl v Ar file_number |
.Fl a Ar file_number | Fl v Ar file_number |
.Oc |
.Oc |
.Op Fl e Ar string |
.Op Fl e Ar string |
.Op Fl j Ar file_number field |
.Op Fl j Ar file_number field |
.Op Fl o Ar list |
.Op Fl o Ar list |
.Bk -words |
|
.Ek |
|
.Op Fl t Ar char |
.Op Fl t Ar char |
.Op Fl \&1 Ar field |
|
.Op Fl \&2 Ar field |
|
.Ar file1 |
.Ar file1 |
.Ar file2 |
.Ar file2 |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
|
|
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. |
.Pp |
.Pp |
|
When the default field delimiter characters are used, the files to be joined |
|
should be ordered in the collating sequence of |
|
.Xr sort 1 , |
|
using the |
|
.Fl b |
|
option, on the fields on which they are to be joined, otherwise |
|
.Nm |
|
may not report all field matches. |
|
When the field delimiter characters are specified by the |
|
.Fl t |
|
option, the collating sequence should be the same as |
|
.Xr sort 1 |
|
without the |
|
.Fl b |
|
option. |
|
.Pp |
|
If one of the arguments |
|
.Ar file1 |
|
or |
|
.Ar file2 |
|
is |
|
.Sq - , |
|
the standard input is used. |
|
.Pp |
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
|
.It Fl 1 Ar field |
|
Join on the |
|
.Ar field Ns 'th |
|
field of |
|
.Ar file1 . |
|
.It Fl 2 Ar field |
|
Join on the |
|
.Ar field Ns 'th |
|
field of |
|
.Ar file2 . |
.It Fl a Ar file_number |
.It Fl a Ar file_number |
In addition to the default output, produce a line for each unpairable |
In addition to the default output, produce a line for each unpairable |
line in file |
line in file |
|
|
The elements of list must be either comma |
The elements of list must be either comma |
.Pq Ql \&, |
.Pq Ql \&, |
or whitespace separated. |
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 |
options.) |
options.) |
|
|
and |
and |
.Fl v Ar 2 |
.Fl v Ar 2 |
may be specified at the same time. |
may be specified at the same time. |
.It Fl 1 Ar field |
|
Join on the |
|
.Ar field Ns 'th |
|
field of file 1. |
|
.It Fl 2 Ar field |
|
Join on the |
|
.Ar field Ns 'th |
|
field of file 2. |
|
.El |
.El |
.Pp |
.Pp |
When the default field delimiter characters are used, the files to be joined |
.Ex -std join |
should be ordered in the collating sequence of |
|
.Xr sort 1 , |
|
using the |
|
.Fl b |
|
option, on the fields on which they are to be joined, otherwise |
|
.Nm |
|
may not report all field matches. |
|
When the field delimiter characters are specified by the |
|
.Fl t |
|
option, the collating sequence should be the same as |
|
.Xr sort 1 |
|
without the |
|
.Fl b |
|
option. |
|
.Pp |
|
If one of the arguments |
|
.Ar file1 |
|
or |
|
.Ar file2 |
|
is |
|
.Dq - , |
|
the standard input is used. |
|
.Pp |
|
The |
|
.Nm |
|
utility exits 0 on success or >0 if an error occurred. |
|
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr awk 1 , |
.Xr awk 1 , |
.Xr comm 1 , |
.Xr comm 1 , |
|
|
.Bl -tag -width Fl |
.Bl -tag -width Fl |
.It Fl a |
.It Fl a |
In addition to the default output, produce a line for each unpairable line |
In addition to the default output, produce a line for each unpairable line |
in both file 1 and file 2. |
in both |
|
.Ar file1 |
|
and |
|
.Ar file2 . |
|
.It Fl j Ar field |
|
Join on the |
|
.Ar field Ns 'th |
|
field of both |
|
.Ar file1 |
|
and |
|
.Ar file2 . |
.It Fl j1 Ar field |
.It Fl j1 Ar field |
Join on the |
Join on the |
.Ar field Ns 'th |
.Ar field Ns 'th |
field of file 1. |
field of |
|
.Ar file1 . |
.It Fl j2 Ar field |
.It Fl j2 Ar field |
Join on the |
Join on the |
.Ar field Ns 'th |
.Ar field Ns 'th |
field of file 2. |
field of |
.It Fl j Ar field |
.Ar file2 . |
Join on the |
|
.Ar field Ns 'th |
|
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 |
.Nm |