Selects or rejects lines common to two sorted files.
Note: If you specify - (minus) for one of the file names, the comm command reads standard input.
The comm command reads the File1 and File2 parameters and writes, by default, a three-column output to standard output. The columns consist of:
Both File1 and File2 should be sorted according to the collating sequence specified by the current National Language environment.
Item | Description |
---|---|
-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). |
This command returns the following exit values:
Item | Description |
---|---|
0 | All input files were output successfully. |
>0 | An error occurred. |
comm things.to.do things.done
If
the files things.to.do and things.done contain the
following lists:
things.to.do
buy soap
groceries
luncheon
meeting at 3
system update
tech. review
things.done
2nd revision
interview
luncheon
system update
tech. review
weekly report
then the comm command 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.comm -23 things.to.do things.done
This
suppresses the second and third columns of the comm command
listing. If the files are the same as in Example 1, then the following
is displayed:
buy soap
groceries
meeting at 3
Item | Description |
---|---|
/usr/bin/comm | Contains the comm command. |