Operating systems, development tools, and professional services
for connected embedded systems
for connected embedded systems
![]() |
![]() |
![]() |
comm
Select or reject lines common to two files (POSIX)
Syntax:
comm [-1] [-2] [-3] file1 file2
Options:
- -1
- (the number one) Suppress writing of lines found only in file1.
- -2
- Suppress writing of lines found only in file2.
- -3
- Suppress writing of lines found in both file1 & file2.
- file1
- A pathname of the first file to be compared. If file1 is -, the standard input is used.
- file2
- A pathname of the second file to be compared. If file2 is -, the standard input is used.
Description:
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 |
Examples:
Print only the lines common to both files:
comm -12 test.dat save.dat
Files:
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.
Exit status:
- 0
- All input files were successfully output as specified.
- >0
- An error occurred.
See also:
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Next]](../next.gif)