Compare binary files
Diff is often used to compare two files line by line, but for binary files you must rely on other tools. My favourite tool for this task is dhex: I often use it to analyze data corruptions.
Determine if two binary files are different
You can compute the checksums of the two files and compare them:
$ md5sum good.mp3 bad.mp3 e54c63ad1efe9baea6d44a1ef836146c good.mp3 933b9d4d4323bf412ee22588db909387 bad.mp3
But since you are not interested in the checksums, it is more simple
to invoke diff
:
$ diff good.mp3 bad.mp3 Binary files good.mp3 and bad.mp3 differ
However, a better alternative is to use cmp
because it tells you
where the difference starts:
$ cmp good.mp3 bad.mp3 good.mp3 bad.mp3 differ: char 3527361, line 17610
View differences between binary files
dhex is an hexadecimal editor but its most convenient feature in my opinion is the diff mode. To enter the diff mode, you have to invoke dhex with two files as parameters:
$ dhex good.mp3 bad.mp3
Then to jump to the first difference, you can press F3.