This reads through both files., In first file you populate an array with keys, and in the second file, you print only the lines with, equivalent of a full outer join join -t'$' -a 1 -a 2 <(sort -k1,1 -t'$' out1.csv, ) <(sort -k1,1 -t'$' out2.csv ) Solution 2: ...