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 FILE2Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -1 | option | First file key field |
| -2 | option | Second file key field |
| -t | option | Field delimiter |
| FILE1 | operand | Sorted input |
| FILE2 | operand | Sorted 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