324
119
I need to compare two binary files and get the output in the form:
<fileoffset-hex> <file1-byte-hex> <file2-byte-hex>
for every different byte. So if file1.bin
is
00 90 00 11
in binary form and file2.bin
is
00 91 00 10
I want to get something like
00000001 90 91
00000003 11 10
Is there a way to do this in Linux? I know about cmp -l
but it uses a decimal system for offsets and octal for bytes which I would like to avoid.
9you're basically looking for "binary diff". i can imagine some reeeally ugly commandline one-liner with
od
... – quack quixote – 2010-03-29T15:36:42.6602@quack quixote: What's ugly about a one-liner? ;) – Bobby – 2010-03-29T16:50:23.907
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 Carroll – 2018-11-09T04:02:18.550Not to mention this is explicitly against the rules on multiple areas, it's about "programming and software development" and you're asking for a product or recommendation rather than how to use a specific product. – Evan Carroll – 2018-11-09T04:04:38.873
Also updated with the method about radare, but I still think this question is both off topic and too vague.
– Evan Carroll – 2018-11-09T04:20:18.9502@EvanCarroll If you think the question is off topic why are you answering it? – DavidPostill – 2018-11-26T21:07:51.903
@DavidPostill I don't think it's off topic. I think it's a great question. I think it's poorly worded and that the admins here would cause undue problems if I otherwise tried to salvage it. See my answer for more information. Binary diff question? YES! Byte for byte diff? Well, that makes no sense in any use case I can imagine. – Evan Carroll – 2018-11-26T22:35:11.813
FreeBSD's
– Conrad Meyer – 2019-11-23T18:01:38.913cmp
has an-x
flag ("heXadecimal") which produces output formatted exactly as specified in the question, in conjunction with-l
:cmp -xl file1.bin file2.bin
. sourcexdelta.org works quite well. Perhaps it'd be worth having a look at it. – thatjuan – 2013-10-10T05:31:23.123