commands

join — join sorted records by key

Combine records sharing a join key, first blank-separated field by default; inputs normally must be sorted on join fields. -1 and -2 select the key field of each file, -t sets delimiter. Duplicate keys may produce multiple pairs. Example assumes a fresh text-streams lab fixture.

Formal Syntax & Structure

linux syntaxlinux
join [OPTION]... FILE1 FILE2

Parameters & Attributes

NameTypeDescription
-1optionFirst file key field
-2optionSecond file key field
-toptionField delimiter
FILE1operandSorted input
FILE2operandSorted input

Return Value

exit status and output

GNU join writes matched records and returns nonzero on errors, including diagnosed input-order violations. No matching keys can yield empty output and status 0; check ordering requirements separately.

Working Example

Example Snippetlinux
LC_ALL=C join join-a.txt join-b.txt
Linux Reference