commands
comm — compare sorted files
Compare sorted inputs in the same locale; columns contain lines unique to first, unique to second, and common to both. -12 suppresses columns 1 and 2, leaving common lines. Example assumes a fresh text-streams lab fixture.
Formal Syntax & Structure
linux syntaxlinux
comm [OPTION]... FILE1 FILE2Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -12 | option | Suppress first two columns |
| FILE1 | operand | Sorted first file |
| FILE2 | operand | Sorted second file |
Return Value
exit status and output
For GNU comm, status 0 means the comparison completed, even when the inputs differ or the selected columns are empty. Nonzero indicates an error; compare the output to identify common or unique lines.
Working Example
Example Snippetlinux
LC_ALL=C comm -12 sorted-a.txt sorted-b.txt