Join two files by matching columns
I am trying to join two files, one has 4 columns the other 3. I want to match the third column of the first to the second column on the second file and add the 3rd column of the second file to the first, when the data from each column match. I managed to do it but only when I output all columns from second file. Like this:
join -t' ' -1 3 -2 2 -o 1.1,1.2,1.3,1.4,2.1 join_2.txt join_1.txt > join_try_3.txt
If I run this, it doesn't work:
join -t' ' -1 3 -2 2 -o 1.1,1.2,1.3,1.4,2.3 join_2.txt join_1.txt > join_try_3.txt
Any ideas why? And suggestions to only add the the 3rd column of the second file would be appreciated.
Thanks in advance.
• 84 views