about comm
compare two sorted files line-by-line
syntax
comm [option]… file1 file2
description
compare sorted files file1 and file2
with no options, comm produces three-column output
- column 1 contains lines unique to
file1 - column 2 contains lines unique to
file2 - column 3 contains lines common to both files
each of these columns can be suppressed individually with options
options
-1suppress column 1 (lines unique to file1)-2suppress column 2 (lines unique to file2)-3suppress column 3 (lines that appear in both files)--check-orderchech that the input is correctly sorted, even if all input lines are pairable--nocheck-orderdo not check that the input is correctly sorted--output-delimiter=strseparate columns with stringstr--helpdisplay a help message and exit--versionoutput version infomation and exit
examples
-
print only the lines present in
bothfile1.txt and file2.txtcomm -12 file1.txt file2.txt -
print only the lines that are present in file1 and not in file2 and vice versa
comm -3 file1.txt file2.txt