JOIN(1)

NAME
join - relational database operator

SYNOPSIS
join [-1 field] [-2 field] [-o list] [-e string] [-a fileno | -v fileno] [-t delim] file1 file2

DESCRIPTION
join lines from file1 and file2 on a matching field. If one of the input files is '-', standard input is read for that file.

Files are read sequentially and are assumed to be sorted on the join field. join does not check the order of input, and joining two unsorted files will produce unexpected output.

By default, input lines are matched on the first blank-separated field; output lines are space-separated and consist of the join field followed by the remaining fields from file1, then the remaining fields from file2.

OPTIONS

-1 field
    Join on the fieldth field of file 1.

-2 field
    Join on the fieldth field of file 2.

-a fileno
    Print unpairable lines from file fileno in addition to normal output.

-e string
    When used with -o, replace empty fields in the output list with string.

-o list
    Format output according to the string list. Each element of list may be either fileno.field or 0 (representing the join field). Elements in list may be separated by blanks or commas. For example,

        join -o "0 2.1 1.3"

    would print the join field, the first field of file2, then the third field of file1.

    Only paired lines are formatted with the -o option. Unpairable lines (selected with -a or -v) are printed raw.

-t delim
    Use the arbitrary string delim as field delimiter for both input and output.

-v fileno
    Print unpairable lines from file fileno instead of normal output.

STANDARDS
The join utility is compliant with the p1003.1-2013 specification with the following exeption:

•   Unpairable lines ignore formatting specified with -o.

The possibility of specifying multibyte delimiters of arbitrary length is an extension to the specification.