comm [OPTION]... FILE1 FILE2
Files FILE1 and FILE2 must be sorted
.
With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.
Note, comparisons honor the rules specified by "LC_COLLATE".
Find lines only in FILE1 by setting -2 and -3:
comm -23 FILE1 FILE2
Find lines only in FILE2 by setting -1 and -3:
comm -13 FILE1 FILE2
Find lines common to both files by setting -1 and -2:
comm -12 FILE1 FILE2