Compare Two Files Using Comm
by Ramesh
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
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .