Comm command is used to compare two sorted files line by line.
syntax: comm [OPTION]... FILE1 FILE2
This command will display the lines unique in file1, lines unique in file2, and lines common to both file1 and file2 as shown below.
In the below example,
- First column displays the lines unique in file1 ( i.e name_list.txt )
- Second column displays the lines unique in file2 ( i.e name_list_new.txt )
- Third column displays the lines that are common in both the files.
$ cat name_list.txt Bram Moolenaar Ken Thompson Linus Torvalds $ cat name_list_new.txt Bram Moolenaar Dennis Ritchie Richard Stallman $ comm name_list.txt name_list_new.txt Bram Moolenaar Dennis Ritchie Ken Thompson Linus Torvalds Richard Stallman