Linux: Binary comparison with "cmp"

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

Linux: Binary comparison with "cmp"

Post by peter_b »

Usually I use "vbindiff" for binary file comparison, but on RedHat (RHEL) systems, it doesn't seem to be in the default repositories.
Thanks to an answer on "superuser.com", I found a substitute by using "cmp":

Code: Select all

$ cmp -l file1.avi file2.avi
That outputs a listing with 3 columns:
  • byte offset
  • value in first file
  • value in second file
For example:
230858726 0 243
230858727 0 266
230858728 0 125
230858729 0 316
230858730 0 117
230858731 0 302
230858732 0 65
It's not as beautiful to read/interact with as vbindiff, but at least it gives you a hint of what's going on.
If you want to count the differences, you can use "wc" in line-mode:

Code: Select all

$ cmp -l file1.avi file2.avi | wc -l

Links:
Post Reply