Reputation: 5059
I have two files (tab delimited) one file is has 4 columns and n number of rows and second file has 2 columns and n number of rows.
column 4 of first file is identical to column 2 of second file.
I want to have a third file which contains first four columns from file 1 and column 5 from file 2.
Any suggestions for one line bash script.
Upvotes: 6
Views: 6442
Reputation: 80761
try with join
join FILE1 FILE2 -1 4 -2 2 -t"tab"
to express a join between the files FILE1 and FILE2 based on the 4th field (-1 4
) of FILE1 and the 2nd field (-2 2
) of FILE2
Upvotes: 9