Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

awk(1)

comm(1)

sort(1)

JOIN(1)

NAME

join − relational database operator

USAGE

join [ options ] file1 file2

DESCRIPTION

Join forms, on the standard output, a union between the two relations specified by the lines of file1 and file2. If file1 is −, the standard input is used. 

File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined (normally, the first in each line). 

One line in the output for each pair of lines in file1 and file2 will have identical join fields.  The output line normally consists of the common field, then the remainder of the line from file1, and finally, the remainder of the line from file2.

The default input field separators are blank, tab, or newline.  Multiple separators usually count as one field separator, and leading separators are ignored.  The default output field separator is a blank. 

OPTIONS

Some of the options below use the argument n. This argument should be a 1 or 2, referring to either file1 or file2, respectively.

−an In addition to the normal output, produce a line for each unpaired line in file n, where n is 1 or 2. 

−e s Replace empty output fields by string s.

−jn m Join on the mth field of file n. If n is missing, use the mth field in each file. Fields are numbered starting with 1.

−o list Let each output line comprise the fields specified in list, each element of which has the form n.m, where n is a file number and m is a field number.  Do not print the common field unless specifically requested. 

−tc Use character c as a separator (tab character) for both input and output.  Every appearance of c in a line is significant. 

EXAMPLE

To join the fourth field of both file1 and file2, type the following:

% join −j1 4 −j2 4 file1 file2

CAUTIONS

With default field separation, the collating sequence is that of sort −b; with −t, the sequence is that of a plain sort(1). 

The conventions used by join are vastly different from those used by sort(1), comm(1), uniq(1), and awk(1). 

RELATED INFORMATION

awk(1), comm(1), sort(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026