Obtaining Unique Line from Unix 'join' -


given these 2 files

file1.txt ------ foo bar file2.txt ------ foo 1 foo 2 bar 31 

how can obtain first line of successful join in file2.txt? expected result after joining is:

foo 1 bar 31 

i tried didn't work:

join file1.txt file2.txt 

what's right join command?

the join tried print both instances of foo file2. if want pick one, use sort ensure there unique entries in both files before actual join:

join <(sort file1) <(sort -k1,1 -u file2) 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -