------------------------------------------------------------------------ comm (find lines common to two files) ------------------------------------------------------------------------ $ comm [-123i] file1 file2 will produce, three columns as output: lines only in file1 lines only in file2 lines in both file1 and file2 file1 and file2 are EXPECTED TO BE SORTED LEXICALLY. option: -1 suppress printing of column 1 -2 suppress printing of column 2 -3 suppress printing of column 3 -i case insensitive comparison You can combine the options as $ comm -12 file1 file2 #suppress line 1 and line 2 #You can use subshells to feed comm $ comm -12 <(sort file1) <(sort file2) EXAMPLE $ cat a1 A B D C $ cat a2 X Z Y A $ comm <(sort a1) <(sort a2) A B C D X Y Z