Linux and Unix comm command
Compare two sorted files line-by-line.
comm [OPTION]... FILE1 FILE2
Compare sorted files FILE1 and FILE2 line-by-line.
With no options, comm produces 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. Each of these columns can be suppressed individually with options.
|-1||suppress column 1 (lines unique to FILE1)|
|-2||suppress column 2 (lines unique to FILE2)|
|-3||suppress column 3 (lines that appear in both files)|
|--check-order||check that the input is correctly sorted, even if all input lines are pairable|
|--nocheck-order||do not check that the input is correctly sorted|
|--output-delimiter=STR||separate columns with string STR|
|--help||display a help message, and exit.|
|--version||output version information, and exit.|
comm -12 myfile1.txt myfile2.txt
Print only the lines present in both myfile1.txt and myfile2.txt.
comm -3 myfile1.txt myfile2.txt
Print only the lines that are present in myfile1.txt and not myfile2.txt, and vice versa.