[BACK]Return to join.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / join

Annotation of src/usr.bin/join/join.1, Revision 1.8

1.3       michaels    1: .\" Copyright (c) 1990, 1993
                      2: .\"    The Regents of the University of California.  All rights reserved.
1.1       deraadt     3: .\"
                      4: .\" This code is derived from software contributed to Berkeley by
                      5: .\" the Institute of Electrical and Electronics Engineers, Inc.
                      6: .\"
                      7: .\" Redistribution and use in source and binary forms, with or without
                      8: .\" modification, are permitted provided that the following conditions
                      9: .\" are met:
                     10: .\" 1. Redistributions of source code must retain the above copyright
                     11: .\"    notice, this list of conditions and the following disclaimer.
                     12: .\" 2. Redistributions in binary form must reproduce the above copyright
                     13: .\"    notice, this list of conditions and the following disclaimer in the
                     14: .\"    documentation and/or other materials provided with the distribution.
                     15: .\" 3. All advertising materials mentioning features or use of this software
                     16: .\"    must display the following acknowledgement:
                     17: .\"    This product includes software developed by the University of
                     18: .\"    California, Berkeley and its contributors.
                     19: .\" 4. Neither the name of the University nor the names of its contributors
                     20: .\"    may be used to endorse or promote products derived from this software
                     21: .\"    without specific prior written permission.
                     22: .\"
                     23: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     24: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     25: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     26: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     27: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     28: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     29: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     31: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     32: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     33: .\" SUCH DAMAGE.
                     34: .\"
1.3       michaels   35: .\"    @(#)join.1      8.3 (Berkeley) 4/28/95
1.1       deraadt    36: .\"
1.3       michaels   37: .Dd April 28, 1995
1.1       deraadt    38: .Dt JOIN 1
                     39: .Os
                     40: .Sh NAME
                     41: .Nm join
                     42: .Nd relational database operator
                     43: .Sh SYNOPSIS
                     44: .Nm join
                     45: .Oo
                     46: .Fl a Ar file_number | Fl v Ar file_number
                     47: .Oc
                     48: .Op Fl e Ar string
                     49: .Op Fl j Ar file_number field
                     50: .Op Fl o Ar list
                     51: .Bk -words
                     52: .Ek
                     53: .Op Fl t Ar char
                     54: .Op Fl \&1 Ar field
                     55: .Op Fl \&2 Ar field
                     56: .Ar file1
                     57: .Ar file2
                     58: .Sh DESCRIPTION
1.6       aaron      59: The
                     60: .Nm
                     61: utility performs an
                     62: .Dq equality join
                     63: on the specified files
1.1       deraadt    64: and writes the result to the standard output.
1.6       aaron      65: The
                     66: .Dq join field
                     67: is the field in each file by which the files are compared.
1.1       deraadt    68: The first field in each line is used by default.
                     69: There is one line in the output for each pair of lines in
                     70: .Ar file1
                     71: and
                     72: .Ar file2
                     73: which have identical join fields.
1.4       millert    74: Each output line consists of the join field, the remaining fields from
1.1       deraadt    75: .Ar file1
1.4       millert    76: and then the remaining fields from
1.1       deraadt    77: .Ar file2 .
                     78: .Pp
                     79: The default field separators are tab and space characters.
                     80: In this case, multiple tabs and spaces count as a single field separator,
                     81: and leading tabs and spaces are ignored.
                     82: The default output field separator is a single space character.
                     83: .Pp
                     84: Many of the options use file and field numbers.
1.6       aaron      85: Both file numbers and field numbers are 1 based, i.e., the first file on
1.1       deraadt    86: the command line is file number 1 and the first field is field number 1.
1.8     ! aaron      87: .Pp
        !            88: The options are as follows:
1.1       deraadt    89: .Bl -tag -width Fl
                     90: .It Fl a Ar file_number
                     91: In addition to the default output, produce a line for each unpairable
                     92: line in file
                     93: .Ar file_number .
1.3       michaels   94: (The argument to
                     95: .Fl a
                     96: must not be preceded by a space; see the
                     97: .Sx COMPATIBILITY
                     98: section.)
1.1       deraadt    99: .It Fl e Ar string
                    100: Replace empty output fields with
                    101: .Ar string .
                    102: .It Fl o Ar list
1.5       aaron     103: Specifies the fields that will be output from each file for
1.1       deraadt   104: each line with matching join fields.
                    105: Each element of
                    106: .Ar list
                    107: has the form
                    108: .Ql file_number.field ,
                    109: where
                    110: .Ar file_number
                    111: is a file number and
                    112: .Ar field
                    113: is a field number.
1.6       aaron     114: The elements of list must be either comma
                    115: .Pq Ql \&,
                    116: or whitespace separated.
1.3       michaels  117: (The latter requires quoting to protect it from the shell, or, a simpler
1.1       deraadt   118: approach is to use multiple
                    119: .Fl o
                    120: options.)
                    121: .It Fl t Ar char
                    122: Use character
                    123: .Ar char
                    124: as a field delimiter for both input and output.
                    125: Every occurrence of
                    126: .Ar char
                    127: in a line is significant.
                    128: .It Fl v Ar file_number
                    129: Do not display the default output, but display a line for each unpairable
                    130: line in file
                    131: .Ar file_number .
                    132: The options
                    133: .Fl v Ar 1
                    134: and
                    135: .Fl v Ar 2
                    136: may be specified at the same time.
                    137: .It Fl 1 Ar field
                    138: Join on the
                    139: .Ar field Ns 'th
                    140: field of file 1.
                    141: .It Fl 2 Ar field
                    142: Join on the
                    143: .Ar field Ns 'th
                    144: field of file 2.
                    145: .El
                    146: .Pp
                    147: When the default field delimiter characters are used, the files to be joined
                    148: should be ordered in the collating sequence of
                    149: .Xr sort 1 ,
                    150: using the
                    151: .Fl b
                    152: option, on the fields on which they are to be joined, otherwise
1.6       aaron     153: .Nm
1.1       deraadt   154: may not report all field matches.
                    155: When the field delimiter characters are specified by the
                    156: .Fl t
                    157: option, the collating sequence should be the same as
                    158: .Xr sort
                    159: without the
                    160: .Fl b
                    161: option.
                    162: .Pp
                    163: If one of the arguments
                    164: .Ar file1
                    165: or
                    166: .Ar file2
1.6       aaron     167: is
                    168: .Ql \&- ,
                    169: the standard input is used.
1.1       deraadt   170: .Pp
                    171: The
1.6       aaron     172: .Nm
1.5       aaron     173: utility exits 0 on success or >0 if an error occurred.
1.1       deraadt   174: .Sh COMPATIBILITY
                    175: For compatibility with historic versions of
                    176: .Nm join ,
                    177: the following options are available:
                    178: .Bl -tag -width Fl
                    179: .It Fl a
                    180: In addition to the default output, produce a line for each unpairable line
                    181: in both file 1 and file 2.
1.3       michaels  182: (To distinguish between this and
                    183: .Fl a Ar file_number ,
1.6       aaron     184: .Nm
1.7       aaron     185: currently requires that the latter not include any whitespace.)
1.1       deraadt   186: .It Fl j1 Ar field
                    187: Join on the
                    188: .Ar field Ns 'th
                    189: field of file 1.
                    190: .It Fl j2 Ar field
                    191: Join on the
                    192: .Ar field Ns 'th
                    193: field of file 2.
                    194: .It Fl j Ar field
                    195: Join on the
                    196: .Ar field Ns 'th
                    197: field of both file 1 and file 2.
                    198: .It Fl o Ar list ...
                    199: Historical implementations of
1.6       aaron     200: .Nm
1.1       deraadt   201: permitted multiple arguments to the
                    202: .Fl o
                    203: option.
1.6       aaron     204: These arguments were of the form
                    205: .Dq file_number.field_number
                    206: as described for the current
1.1       deraadt   207: .Fl o
                    208: option.
1.6       aaron     209: This has obvious difficulties in the presence of files named
                    210: .Dq 1.2 .
1.1       deraadt   211: .El
                    212: .Pp
1.5       aaron     213: These options are available only so historic shell scripts don't require
1.1       deraadt   214: modification and should not be used.
1.8     ! aaron     215: .Sh SEE ALSO
        !           216: .Xr awk 1 ,
        !           217: .Xr comm 1 ,
        !           218: .Xr paste 1 ,
        !           219: .Xr sort 1 ,
        !           220: .Xr uniq 1
1.1       deraadt   221: .Sh STANDARDS
                    222: The
1.6       aaron     223: .Nm
1.1       deraadt   224: command is expected to be
                    225: .St -p1003.2
                    226: compatible.