join

Joining by first column

join file1 file2
  • joining works by default by first column

  • the files need to be sorted in the same direction

Joining by a different column

  • in case you want to join by different column use following:

join -1 1 -2 3 file1 file2

joins by the first column of file1 and third column of file2

Joining when files have delimiter

join -1 1 -2 3 -t , file1.csv file2.csv

Do a left join

join -a 1 file1 file2

the -a 1 flag means that even the umatched lines from the first file wil be joined

Specifying the output

Last updated