Linux – Comparing two files byte by byte


cmp:
command can be used to compare two files byte by byte.
Some useful option of this command, which I use are as below :

-b : print differing bytes
-l : output byte numbers and values of all differing bytes

Example: 

cat test1.txt 
Hello World
cat test2.txt
hello world

cmp with no option set

cmp test1.txt test2.txt 
test1.txt test2.txt differ: byte 1, line 1

cmp with verbose output

cmp -bl test1.txt test2.txt 
1 110 H 150 h
7 127 W 167 w

 

 

Leave a Reply