1

Say I've got two binary files, each roughly 50MB, that may contain a digitally-identical portion. Is there an easy way to compare these two files, find the longest identical portion, and save that to a file?

(If it matters, the files in question are stream-capture AAC files. They've got some audio boilerplate that sounds identical, but it may or may not be digitally identical. So I've got a two part task: first determine if the boilerplate is digitally identical, second extract the identical portion.)

  • rsync has at its core a clever technique to locate same and ":changed" regions of two usually large files using only small information from one of them, accessed across a potentially costly network, see en.wikipedia.org/wiki/Rsync#Algorithm . The program has accreted options to manage syncing whole trees of files across many kinds of transports and platforms, but you might be able to extract the core algorithm and use it. Or go back to Tridgell's original work and build forward. – dave_thompson_085 Sep 29 '15 at 7:08
0

I recommend you to use cmp it is quite useful and got nice options like -b if you want to print bytes that differ and -l to be more verbose. For instance to compare a and b file use a command line like:

$ cmp -lb a b

It will output you all bytes that differ. If both file are the same, cmp will quietly return (you can always check its return value $? ) Note that cmp with -b option will output only bytes that differ and that if you do not use -l option, it will stop on the first byte that differ.

  • cmp will only help find matching portions that start at the same offset in both files. – Gilles Sep 27 '15 at 21:41
  • Offset of the potentially matching bytes are definitely not going to be the same, so I guess that means that cmp is out. – mikeola Sep 28 '15 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.