Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (c) comm(1)
NAME
comm - Compares two sorted files
SYNOPSIS
comm [-123] file1 file2
The comm command reads file1 and file2 and writes three columns to the standard output
file, showing which lines are common to both files and which are unique to each file.
FLAGS
-1 Suppresses output of the first column (lines only in file1).
-2 Suppresses output of the second column (lines only in file2).
-3 Suppresses output of the third column (lines common to file1 and file2).
The command comm -123 produces no output.
DESCRIPTION
The leftmost column of the standard output file includes lines that are only in file1. The middle
column includes lines that are only in file2. The rightmost column includes lines that are in both
file1 and file2. Columns are separated by tab characters.
If you specify - (dash) in place of one of the filenames, the comm command reads the standard
input file.
The file1 and file2 arguments should be sorted according to the collating sequence specified by
the LC_COLLATE environment variable (see the reference page for the sort command), or the
comm command fails.
EXAMPLES
In the following examples, file file1 contains the following sorted list of North American cities:
Anaheim
Baltimore
Boston
Chicago
Cleveland
Dallas
Detroit
Kansas City
Milwaukee
Minneapolis
New York
Oakland
Seattle
Toronto
527188-007 Hewlett-Packard Company 2−63