Specify alternate join fields.
Section: join and comm
Join on a different field number
bash
bash
join -1 2 -2 1 left.txt right.txtExplanation
Use `-1` and `-2` to choose the join field in each file.
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 two files on a common field
Merge records based on matching first fields.
Show common lines between sorted files
Print only lines present in both files.
Show lines only in the first file
List lines unique to the first sorted file.
Show lines only in the second file
List lines unique to the second sorted file.
Extract comma-delimited fields
Print the first and third fields from a CSV-like file.