Name

comm — stdin  stdout  - file  -- opt  --help  --version

Synopsis

comm [options] file1 file2

The comm command compares two sorted files and produces three columns of output, separated by tabs:

  1. All lines that appear in file1 but not in file2.

  2. All lines that appear in file2 but not in file1.

  3. All lines that appear in both files.

For example, if file1 and file2 contain these lines:

file1:                           file2:
apple            baker
baker            charlie
charlie          dark

then comm produces this three-column output:

$ comm file1 file2
apple
                baker
                charlie
        dark

Useful options

−1

Suppress column 1.

−2

Suppress column 2.

−3

Suppress column 3.

Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.