[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Why not diff binaries?

"Pavel M. Penev" <kal_pav@sz.techno-link.com> writes:
>Can someone tell me a sensible reason for not having a 'diff' equivalent
>for binary file?

There is "cmp", but it reports only the position of the first
differing byte (if any).

As for why not:

 * diff is helped a lot by the fact that the input is line-based text.
   And diff doesn't work very well if the lines are very short or
   there are lots of small changes inside lines.

   I don't know if there are algorithms for detecting differences in
   streams of bytes (instead of lines); probably there are, but I
   don't know if they work as well as the text comparison algorithm in

   (There is also wdiff, which works word-wise, and seems to work okay
   for what it's designed: calculating differences between reformatted
   paragraphs of text.)

 * There isn't as much use for binary patches than for textual ones,
   because binary executables are platform-dependent.

It should be possible to dump the binary files in a textual format
with "od" (use one byte or word per line, unless you know the data has
larger structures that you want to compare as a whole) and run diff on
those, but I don't know how well that would work.

-=- Rjs -=- rjs@lloke.dna.fi

Reply to: