COMM(1,C) AIX Commands Reference COMM(1,C)
-------------------------------------------------------------------------------
comm
PURPOSE
Selects or rejects lines common to two sorted files.
SYNTAX
+----------------+
| one of |
comm --|+--------------+|--- file1 --- file2 ---|
|| -1 -2 -3 ||
+| -12 -13 -23 |+
| -123 |
+--------------+
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, the comm command reads
standard input. Both file1 and file2 should be sorted according to the
collating sequence specified by the environment variables LANG and LC_COLLATE
(see "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 no-op).
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:
Processed November 8, 1990 COMM(1,C) 1
COMM(1,C) AIX Commands Reference COMM(1,C)
+--------------+--------------+
|things.to.do | things.done |
+--------------+--------------+
| | |
| buy soap | 2nd revisio|
| groceries | interview |
| luncheon | luncheon |
| meeting at 3| system upda|e
| system updat| tech. revie|
| tech. review| weekly repo|t
| | |
+--------------+--------------+
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 the file "things.to.do".
The second column, indented with a tab character, lists the lines found
only in the file "things.done". The third column, indented with two tabs,
lists the lines common to both files.
2. To display the lines that appear in only one file:
comm -23 things.to.do things.done
This command suppresses the display of second and third columns of the comm
command listing. If the files are the same as in Example 1, the following
lines are displayed:
buy soap
groceries
meeting at 3
RELATED INFORMATION
See the following commands: "cmp," "diff," "sdiff," "sort," and "uniq."
See the environment miscellaneous facility in AIX Operating System Technical
Reference.
See "Overview of International Character Support" in Managing the AIX Operating
System.
Processed November 8, 1990 COMM(1,C) 2