xdelta.org works quite well. Perhaps it'd be worth having a look at it.
– thatjuanOct 10 '13 at 5:31

Because you can't answer this question (as you're not a user), I'm voting to close. A binary diff as explicitly requested here isn't at all useful, and I'm inclined to think you want something useful, if you insert one byte at the start of the file should all bytes be marked as being different? Without knowing that, this is simply too vague.
– Evan CarrollNov 9 '18 at 4:02

1

@EvanCarroll If you think the question is off topic why are you answering it?
– DavidPostill♦Nov 26 '18 at 21:07

@gertvdijk: strtonum is specific to GAWK. I believe Ubuntu previously used GAWK as the default, but switched at some point to mawk. In any case, GAWK can be installed and set to the default (see also man update-alternatives). See my updated answer for a solution that doesn't require strtonum.
– Dennis WilliamsonJul 4 '13 at 18:08

In Bash: diff <(xxd b1) <(xxd b2) but the output format of this (or yours) is nowhere near what the OP asked for.
– Dennis WilliamsonMar 29 '10 at 16:33

6

with vimdiff it is, it will color the bytes in the lines where the two 'files' differ
– akiraMar 30 '10 at 4:45

Aww, why didn't I think of that? And I'm sure I've used this technique in the past too.
– njdMar 30 '10 at 17:37

1

This worked great for me (with opendiff on OS X instead of vimdiff) — the default view xxd provides keeps the diff engine on track comparing byte-by-byte. With plain (raw) hex simply column-fit with fold, diff would try to fold/group random stuff in the files I was comparing.
– natevwNov 15 '14 at 23:26

1

This command does not work well for byte addition removal, as every line that follows will be misaligned and seen as modified by diff. The solution is to put 1 byte per line and remove the address column as proposed by John Lawrence Aspden and me.
– Ciro Santilli 新疆改造中心 六四事件 法轮功Apr 4 '15 at 20:38

DHEX is awesome is comparing binaries is what you want to do. Feed it two files and it takes you right to a comparative view, highlighting to differences, with easy ability to move to the next difference. Also it's able to work with large terminals, which is very useful on widescreen monitors.
– MarcinSep 8 '11 at 0:08

6

I prefer VBinDiff. DHEX is using CPU even when idling, I think it's redrawing all the time or something. VBinDiff doesn't work with wide terminals though. But the addresses become weird with wide terminals anyway, since you have more than 16 bytes per row.
– Janus TroelsenOct 17 '12 at 14:22

@DanielBeauyat compressed files will be completely different after you encounter the first different byte. The output is not likely to be useful.
– Mark RansomAug 5 '15 at 3:12

2

@1111161171159459134 jdiff is part of a "suite" of programs to sync and patch the differences found by jdiff. But, as Mark Ransom said, that would be generally not wise on compressed files; the exception is "synchronizable" compressed formats (like that produced by gzip --rsyncable), in which small differences in the uncompressed files should have a limited effect on the compressed file.
– hmijailFeb 13 '16 at 11:12

-An removes the address column. This is important otherwise all lines would differ after a byte addition / removal.

-w1 puts one byte per line, so that diff can consume it. It is crucial to have one byte per line, or else every line after a deletion would become out of phase and differ. Unfortunately, this is not POSIX, but present in GNU.

-tx1 is the representation you want, change to any possible value, as long as you keep 1 byte per line.

When using hexdumps and text diff to compare binary files, especially xxd, the additions and removals of bytes become shifts in addressing which might make it difficult to see. This method tells xxd to not output addresses, and to output only one byte per line, which in turn shows exactly which bytes were changed, added, or removed. You can find the addresses later by searching for the interesting sequences of bytes in a more "normal" hexdump (output of xxd first.bin).

@EvanCarroll true, and hence I left a comment (only) and did not downvote
– MurmelNov 9 '18 at 17:52

I also didn't down vote Mick, but I agree with you and answered here superuser.com/a/1373977/11116 because it seems likely that this bad question will get reformed or closed.
– Evan CarrollNov 9 '18 at 19:06

DHEX is a more than just another hex editor: It includes a diff mode, which can be used to easily and conveniently compare two binary files. Since it is based on ncurses and is themeable, it can run on any number of systems and scenarios. With its utilization of search logs, it is possible to track changes in different iterations of files easily.

Welcome to SuperUser! Although this software looks like it could solve the OP's problem, pure advertisement is strongly frowned upon on the Stack Exchange network. If you are affiliated to this software's editor, please disclose this fact. And try to rewrite your post so that it looks less like a commercial. Thank you.
– Nathan.Eilisha ShirainiAug 18 '17 at 13:31

I am not affiliated with dhex in any way. I copied the author's description into the post because there is minimum post length limit
– Vincent VegaAug 19 '17 at 13:59

Can it be used on arbitrary binary files, though? That page seems to indicate that it's only useful for comparing executables that have been disassembled by Hex-Rays IDA Pro.
– eswaldApr 29 '16 at 22:57

The go to open source product on Linux (and everything else) is Radare which provides radiff2 explicitly for this purpose. I voted to close this because myself and others have the same question, in the question you ask

for every different byte

That's insane though. Because as asked, if you insert one byte at the first byte in the file, you'd find every subsequent byte was different and so the diff would repeat the whole file, for an actual difference of one byte.

Slightly more practical is radiff -O. The -O is for ""Do code diffing with all bytes instead of just the fixed opcode bytes""