Text and processing
The join command
Combines two files by a common field, like a database query but with text.
Syntax
join archivo1 archivo2Most useful options
-1 NJoin field of the first file-2 NJoin field of the second-a NAlso includes lines with no matchCopy-ready examples
$ printf '1 ana\n' > j1.txt && printf '1 madrid\n' > j2.txt && join j1.txt j2.txtJoin on the first fieldYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- The files must be sorted by the join field.
FAQ
What if there is no match?
By default that line disappears; with -a it is kept.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course