HowTo: Compare binary files on Linux

Step-by-Step descriptions of how to do things.

HowTo: Compare binary files on Linux

Postby peter_b » Thu Aug 08, 2019 3:24 am

If you use "diff" to compare binary files (that have the same size), it will just tell you that:
Binary files A and B differ


If you want to know the which bytes at which offsets differ, use the "cmp" command:
Code: Select all
$ cmp -l a.bin b.bin


Without the "-l" parameter, cmp will just tell you the first offset that differs.

With "-l" it will give you an output that looks somewhat like this:
Code: Select all
     173  50 362
    9067  63  67
    9068  70  60
    9069  65  62


According to cmp's manpage, it's "byte numbers and differing byte values".
The first column is the byte offset in decimal (CAUTION: starts at 1 not 0), but I haven't figured out yet what the values of column 2 or 3 mean. In my case here it's neither the value in each file, nor the difference, nor anything.

However: cmp is nice to see how many bytes at which offsets differ! :D
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 302
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 1 guest

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 5 guests

cron
Reputation System ©'