utility

comm — external utility

Compares two sorted text inputs, producing lines unique to the first, unique to the second, and common to both. -1, -2 and -3 suppress corresponding columns. Use the same locale for sorting and comparison. Success does not imply equality. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): b; c.

Formal Syntax & Structure

bash syntaxbash
comm [-123] FILE1 FILE2

Parameters & Attributes

NameTypeDescription
FILE1pathFirst sorted input.
FILE2pathSecond sorted input.

Return Value

exit status

Zero on successful operation; nonzero on errors.

Working Example

Example Snippetbash
printf 'a\nb\nc\n' > leftprintf 'b\nc\nd\n' > rightLC_ALL=C comm -12 left right
Bash Reference