Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diff for 3 binary files

I have 3 binary files. Let's call them file1.bin, file2.bin and file3.bin.

  • file1.bin and file2.bin have some common parts.
  • file2.bin and file3.bin have some common parts.

I want to find the common parts between file1.bin and file2.bin that are different between file2.bin and file3.bin.

How do you recommend to accomplish that? I have already dumped the binary files to text files using xxd and then did a 3-way diff using vim -d file1.txt file2.txt file3.txt.

However, vim marks a part as changed in all the files even if it has only changed in one file and remains the same in the other two files. I want those special kind of occurrences to be marked differently.

like image 481
Dimme Avatar asked Dec 30 '11 10:12

Dimme


1 Answers

Perhaps you can use the built-in unix diff (I think it is part of OSX), but use the --unchanged-group-format to list the similarities. Do that for file1 and file 2. Then do it for file2 and file3. You can then do a regular diff on the two resulting files.

For an idea of how to get the similarities, have a look at this post.

like image 108
Jason Down Avatar answered Sep 21 '22 12:09

Jason Down