Friday, November 18, 2016

linux join two tables based on two columns

join -j 2 -o 1.1,1.2,1.3,2.3 file1 file2
Important: this assumes your files are sorted (as in your example) according to the SNP name. If they are not, sort them first:
join -j 2 -o 1.1,1.2,1.3,2.3 <(sort -k2 file1) <(sort -k2 file2)


reference:
http://unix.stackexchange.com/questions/113898/how-to-merge-two-files-based-on-the-matching-of-two-columns

No comments:

Post a Comment