-
Notifications
You must be signed in to change notification settings - Fork 416
comm
Deekshith SN edited this page Jan 29, 2021
·
2 revisions
The comm command compares two sorted files, it gives 3 columnar output
- first column contains lines unique to the first file
- second column contains lines unique to the second file
- third column displays the common lines
syntax
comm [options]... File1 File2
| Options | Function |
|---|---|
| -1 | Does not display column 1 (does not display lines found only in file1). |
| -2 | Does not display column 2 (does not display lines found only in file2). |
| -3 | Does not display column 3 (does not display lines found in both files). |
| -i | Case insensitive comparison of lines. |
| --check-order | Check the order of the input, even if all input lines are pairable |
| --nocheck-order | Ignore the order of the input |
| --output-delimiter=STR | delimates columns with delimeter “STR” |
| --help | Displays a help menu |
| --version | Display command version information |
Examples
- $ cat words.txt
Apple
Banana
Orange
India
US
Canada
- $ cat countries.txt
India
US
Canada
- $ comm -23 < (sort words.txt | uniq) < (sort countries.txt | uniq)
Apple
Banana
Orange
- $ comm -12 < (sort words.txt | uniq) < (sort countries.txt | uniq)
India
US
Canada
NOTE: While the options provided here work on most UNIX systems, some UNIX flavors may have changed their meanings or uses. If you experience an incompatibility with these options, please consult the manual page (see man command) on your system for a list of compatible options.
UNIX