join
text_processingLinux/Unix
The join command is one of the most frequently used commands in Linux/Unix-like operating systems. join Join lines of two files on a common field
Quick Reference
Command Name:
join
Category:
text_processing
Platform:
Linux/Unix
Basic Usage:
join [options] [arguments]
Common Use Cases
Syntax
join [options] file1 file2
Options
Option | Description |
---|---|
-a FILENUM |
Print unpairable lines from file FILENUM (1 or 2) |
-e STRING |
Replace missing input fields with STRING |
-i, --ignore-case |
Ignore case differences when comparing fields |
-j FIELD |
Equivalent to '-1 FIELD -2 FIELD' |
-o FORMAT |
Obey FORMAT while constructing output line |
-t CHAR |
Use CHAR as input and output field separator |
-v FILENUM |
Like -a FILENUM, but suppress joined output lines |
-1 FIELD |
Join on this FIELD of file 1 |
-2 FIELD |
Join on this FIELD of file 2 |
--check-order |
Check that input is correctly sorted, even if all input lines are pairable |
--nocheck-order |
Do not check that input is correctly sorted |
--header |
Treat first line in each file as field headers |
--help |
Display help and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the join
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
join file1.txt file2.txt