a - comm command comm command is used to compare two sorted files. It produces three columns as output. The 1st contains lines unique to the first file,the 2nd contain lines unique to the second file and the 3rd common to both files common options: -1 → suppresses the fist column -2 → suppresses the second column -3 → suppresses the third column - → reads from standard input comm file1.txt file2.txt → compares two files and shows the 3 columns comm -1 file1.txt file2.txt → compares two files and and skip unique lines to the 1st file comm -2 file1.txt file2.txt → compares two files and and skip unique lines to the 2nd file comm -3 file1.txt file2.txt → compares two files and and skip common lines to both files cat file1.txt | comm - file2.txt → read from cat and compare the two files
b - diff command diff command is used to compare files line by line and show the differences It is useful for comparing small and large files, scrips, configurations etc common option: -u → unified format, before and after block of changed lines -y → output in column format -r → compare directories diff file1.txt file2.txt → show the differences → refers to the content of the first file → refers to the content of the second file. First numbers → corresponds to the first file and second numbers → corresponds to the second file a → add b → change c → delete
c - diff command column and context mode diff -y file1.txt file2.txt → show the differences side by side and → refers to the content of the 1st or 2nd file | → indicated that it needs to be changed diff -c file1.txt file2.txt → show the differences side in context mod *** → the first file '---' → the second file - → to be deleted at the first file + → to be added to the first file ! → to be changed