Select or reject lines common to two files (POSIX)
comm [-1] [-2] [-3] file1 file2
The comm utility reads file1 and file2, which must be ordered in collating sequence (see the sort utility), and produces three text columns as output.
This column: | Contains: |
---|---|
1 | lines found only in file1 |
2 | lines found only in file2 |
3 | lines found in both files |
Print only the lines common to both files:
comm -12 test.dat save.dat
The standard input is used only if specified as a dash (-) command-line file parameter.
All input files must be text files for comm to produce a meaningful result.
The results of the comparison will be written to standard output.
Errors will result in diagnostic messages being written to standard error.