3 个二进制文件的差异

发布于 2024-12-23 11:27:39 字数 599 浏览 0 评论 0原文

我有 3 个二进制文件。我们将它们命名为 file1.binfile2.binfile3.bin

  • file1.binfile2.bin 有一些共同的部分。
  • file2.binfile3.bin 有一些共同的部分。

我想找到 file1.binfile2.bin 之间的共同部分,而 file2.binfile3.bin 之间的不同之处

您建议如何实现这一目标?我已经使用 xxd 将二进制文件转储到文本文件,然后使用 vim -d file1.txt file2.txt file3.txt 进行了 3 向 diff。

然而,vim 会将所有文件中的某个部分标记为已更改,即使该部分仅在一个文件中发生更改并且在其他两个文件中保持不变。我希望对那些特殊的事件进行不同的标记。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉态萌生 2024-12-30 11:27:40

也许您可以使用内置的 unix diff(我认为它是 OSX 的一部分),但使用 --unchanged-group-format 来列出相似之处。对文件 1 和文件 2 执行此操作。然后对文件 2 和文件 3 执行此操作。然后,您可以对两个结果文件进行常规比较。

有关如何获得相似性的想法,请查看 这篇文章

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.

护你周全 2024-12-30 11:27:40

我使用的工具 (ECMerge) 就是这样做的。您只需比较 3 个二进制文件,它将在彼此前面呈现相等的部分,并将修改后的字节适当地放置在之间。无需首先获取十六进制转储。您可以在 JavaScript 中编写脚本,根据差异结果和文件中的字节输出您喜欢的任何内容(它也可以在命令行中使用)。

The tool that I work for (ECMerge) does that. You just have to diff the 3 binary files, it will present equal portions in front of each other, and modified bytes appropriately placed in between. No need to first get an hex dump. You can script in JavaScript to output whatever you like based on the diff results and the bytes in the files (it works also in command line).

一刻暧昧 2024-12-30 11:27:40

Chromium 使用 bsdiff,然后切换到 courgette 进行二进制比较,如其博客 此处。您可能会从他们的博客中找到有用的线索。

Chromium uses bsdiff, then switched to courgette for doing binary diff as explained in their blog here. You might find useful leads from their blog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文