diff and comm Commands

Displays difference of 2 files in same console.
Here "<" represents unique lines in dir1.txt and ">" 
represents unique lines in dir2.txt.
# diff -y dir1.txt dir2.txt
eg:
In below example the sum of unique entries in dir1.txt is listed.
# diff -y dir1.txt dir2.txt | grep "<" | wc -l

comm command usage:

Here its necessary to have both files sorted.
# sort file1

# sort file2

# comm -23 file1 file2
displays lines unique in file1 -23
displays lines unique in file2 -13
displays lines unique in both file1 and file2, 2 coloumns 
in same console -3
displays lines common in both files -12

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *