Merge records based on matching first fields.

Section: join and comm

Join two files on a common field

bash
bash
join users.txt departments.txt
Explanation

Both input files should usually be sorted on the join field first.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing join and comm
Join on a different field number
Specify alternate join fields.
OpenIn sheetbashsame section
Show common lines between sorted files
Print only lines present in both files.
OpenIn sheetbashsame section
Show lines only in the first file
List lines unique to the first sorted file.
OpenIn sheetbashsame section
Show lines only in the second file
List lines unique to the second sorted file.
OpenIn sheetbashsame section
Merge files side by side
Combine lines from two files into columns.
OpenIn sheetbash1 tag match
Extract comma-delimited fields
Print the first and third fields from a CSV-like file.