GNU/Linux Command – JOIN

join — Join lines of 2 files on a common field

Summary:
It will join lines from two files based on a common field which is identical in both files and show the joined line on the screen. By default, join field is the 1st field and space is the default delimiter. The join filed must in sorted order in both files. Output can be saved by redirecting to a file.

Example: $ join f1 f2 -- Join f1 and f2 based on 1st field. $ join -a 1 f1 f2 -- Apart from printing joined line, print the unpairable lines from file 1 alone. $ join -v 2 f1 f2 -- Print only the unpairable lines from file 2. $ join -e "XX" f1 f2 -- In the output, replace the missing inputfield with the string "XX". $ join -i f1 f2 -- Ignore the case, while joining. $ join -j 2 f1 f2 -- Join the files based on the 2nd field in both. $ join -1 2 -2 3 f1 f2 -- Join the files based on the 2nd filed in the 1st file and 3rd field in the 2nd file. $ join -t : f1 f2 -- Fields are delimited by colon char.
Read: man join

Advertisements
Tagged with: ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: