Comm (command)
- The correct title of this article is comm. The initial letter is capitalized due to technical restrictions.
comm is a command line tool that is used to compare two files. It shows common lines in one column and differing lines in separate columns for left and right files. This functionally is similar to diff.
One notable difference between comm and diff is that comm will not try to indicate that a line has "changed" between the two files; lines are either shown in the "from file #1", "from file #2", or "in both" columns. This feature can be especially useful when you wish two lines to be considered different even if they only have subtle differences.
Example usage
Let's say you have two files, foo and bar, and you would like to know what is unique or the same in these two files.
- The foo file has the following lines:
pears mellons
- The bar file has the following lines:
apples oranges pears
To find what lines are common in both of these files, type the following:
comm -12 foo bar
which will produce:
pears
To find what lines are unique to foo, type the following:
comm -23 foo bar
which will produce:
mellons
See also
External links
- [1] The programme's manpage