ArticleDirectory
- Parameters
- Option
- Note:
- Example
Compare sorted files
Comm [Options]File1 file2
Comm compares two sorted files row by row. The display result includes three columns:
Column 1st is a row found only in file1, Column 2nd is a row found only in file2, and column 3rd is a public row of two files.
Parameters
ParametersFile1AndFile2IsCommThe path name of the file to be compared. Use a hyphen(-)To replaceFile1OrFile2,CommReads the input information from the standard input.
Option
-1: The 1st column is not displayed (that is, only the rows found in file1 are not displayed)
-2: The 2nd column is not displayed (that is, only the rows found in file2 are not displayed)
-3: do not display the 3rd columns (that is, do not display the rows found in both files)
Note:
If files are not sorted, comm cannot work normally.
There is a tab in front of no row in Column 2nd and two tabs in front of each row in column 3rd
Example
Original file
$CatAbbbbbcccccdddddeeeeefffff $CatBaaaaadddddeeeeeggggghhhhh
Comm
$ Comm a B aaaaabbbbbccccc ddddd eeeeefffff ggggg hhhhh $
Compare sorted files A and B
Comm-12
$ Comm-12A B dddddeeeee
Show only public rows