COHERENT manpages

This page displays the COHERENT manpage for join [Join two data bases].

List of available manpages
Index


join -- Command

Join two data bases
join [-a [n] ] [-e string ] [-j[n] keyf] [-o n.m ...] [-tc] file1 file2

join processes  the text files  file1 and file2,  each of which  contains a
relational data  base.  If either file  name is `-', the  standard input is
used for that file.

For the purposes  of join, a data base file  contains a set of records, one
per input  line.  Each  record contains  a number of  fields. One  field is
differentiated as key field for each file.  Each file must be sorted by key
field, for example with sort.

By default, the key field is the first field in each record.  The -j option
changes the  key field number  to keyf for  the desired file.   In this and
other options below, the optional file number n must be 1 to indicate file1
or 2 to indicate file2. If no n is given, both file1 and file2 are assumed.

Normally,  fields are  separated by  any amount of  white space  (blanks or
tabs).  Leading blanks or tabs are not considered part of the fields.  With
the -t  option, the separator character is c.  With this option zero-length
fields are  possible; every occurrence  of the separator  ends the previous
field and starts a new one.

Output consists  only of  records for  which the key  field occurs  in both
files.  As  a consequence of the  sorted order of the  input, the output is
also sorted by the key field.   Each output record has first the key field,
then each  field from  the file1  record but the  key field, and  then each
field from the file2 record but the key field.  Fields are separated in the
output with the specified field character,  or with a space character if no
-t option was given.  Output  records are always terminated with a newline.
Under the -e option, string is printed for each empty field.

The -a  option enables printing  of records found  in only file n.  If n is
missing, unpaired  records are  printed from  both input files.   To output
only certain  fields, the -o  option precedes a  list of desired  fields to
print.  Each element is of the form n.m where n is the file number and m is
the field number.

For example,

    join -t: -j1 3 -o 1.3 2.4 1.4 1.1 2.2 filea fileb

joins  filea and  fileb  which have  fields  separated by  the colon  (`:')
character.  The  join field number  is 3 for  filea and 1  (by default) for
fileb. The selected five fields are produced in the output.

See Also

awk,
comm,
commands,
sort,
uniq