This tutorial explains Linux “comm” command, options and its usage with examples.
Compares two files and tells you what line numbers are different.
comm [OPTION]… FILE1 FILE2
Suppress the output column of lines unique to file1.
Suppress the output column of lines unique to file2.
Suppress the output column of lines duplicated in file1 and file2.
Name of the first file to compare.
Name of the second file to compare.
Two provide examples for this command, lets consider two files :
$ cat file1.txt abc def ghi $ cat file2.txt abc ghi klm
In the below examples,
First column displays the lines unique in file1
Second column displays the lines unique in file2
Third column displays the lines that are common in both the files.
1. Simple Command Usage
$ comm file1.txt file2.txt abc def ghi klm
2. Suppress first column
$ comm -1 file1.txt file2.txt abc ghi klm
3. Suppress second column
$ comm -2 file1.txt file2.txt abc def ghi
3. Suppress third column
$ comm -3 file1.txt file2.txt def klm
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.