comm
PURPOSE
Selects or rejects lines common to two sorted files.
SYNOPSIS
comm [ - [ 123 ] ] file1 file2
DESCRIPTION
The comm command reads file1 and file2 and writes, by
default, a three-column output to standard output. The
columns consist of:
1. Lines that are only in file1
2. Lines that are only in file2
3. Lines that are in both file1 and file2.
If you specify - (minus) for one of the file names, comm
reads standard input. Both file1 and file2 should be
sorted according to the collating sequence specified by
the environment variable NLCTAB (see "ctab" and "sort"),
FLAGS
-1 Suppresses the display of the first column (lines
in file1).
-2 Suppresses the display of the second column (lines
in file2).
-3 Suppresses the display of the third column (lines
common to file1 and file2).
Note: Specifying -123 does nothing (a noop).
EXAMPLES
1. To display the lines unique to each file and common
to both:
comm things.to.do things.done
If the files "things.to.do" and "things.done"
contain:
+---------------+---------------+
| things.to.do | things.done |
+---------------+---------------+
| buy soap | 2nd revision|
| groceries | interview |
| luncheon | luncheon |
| meeting at 3| system updat|
| system updat| tech. review|
| tech. review| weekly repor|
+---------------+---------------+
then comm displays:
2nd revision
buy soap
groceries
interview
luncheon
meeting at 3
system update
tech. review
weekly report
The first column contains the lines found only in
"things.to.do". The second column, indented with a
tab character, lists the lines found only in
"things.done". The third column, indented with two
tabs, lists the lines common to both.
2. To display the lines that appear in only one file:
comm -23 things.to.do things.done
This suppresses the second and third columns of the
comm listing. If the files are the same as in
Example 1, then the following is displayed:
"
buy soap
groceries
meeting at 3 "
RELATED INFORMATION
The following commands: "cmp," "ctab," "diff,"
"sdiff," "sort," and "uniq."
The environment miscellaneous facility in AIX Operating
System Technical Reference.
"Overview of International Character Support" in Managing
the AIX Operating System.