bash - 比较来自 zip 文件中 2 个不同路径的 2 个文件名(如果可能,包括内容)
问题描述
有没有办法使用 shell 脚本比较 zip 文件中 2 个不同路径的文件名(如果可能,包括内容)?
我要比较的文件:
第一个 zip 文件(A):包含另一个 zip 文件(A.1),我需要比较的文件是 zip 文件(A.1)中的文件。
第二个zip文件(B):包含一个文件夹,文件夹内的文件是我需要与zip文件(A.1)中的文件进行比较的文件
是否有任何脚本或代码或命令可以用来比较这些 zip 文件中的文件?
解决方案
这是为以下用途而设计的用例diffoscope
:
$ echo 1 > foo
$ echo 2 > bar
$ echo 3 > baz
$ zip 1.zip foo bar baz
adding: foo (stored 0%)
adding: bar (stored 0%)
adding: baz (stored 0%)
$ rm baz
$ echo 4 > foo
$ zip 2.zip foo bar
adding: foo (stored 0%)
adding: bar (stored 0%)
$ diffoscope --no-progress 1.zip 2.zip
--- 1.zip
+++ 2.zip
├── zipinfo /dev/stdin
│ @@ -1,5 +1,4 @@
│ -Zip file size: 430 bytes, number of entries: 3
│ --rw-r--r-- 3.0 unx 2 tx stor 18-May-24 03:46 foo
│ +Zip file size: 294 bytes, number of entries: 2
│ +-rw-r--r-- 3.0 unx 2 tx stor 18-May-24 03:47 foo
│ -rw-r--r-- 3.0 unx 2 tx stor 18-May-24 03:46 bar
│ --rw-r--r-- 3.0 unx 2 tx stor 18-May-24 03:46 baz
│ -3 files, 6 bytes uncompressed, 6 bytes compressed: 0.0%
│ +2 files, 4 bytes uncompressed, 4 bytes compressed: 0.0%
├── foo
│ @@ -1 +1 @@
│ -1
│ +4
推荐阅读
- system-calls - 为什么未设置 mmap 系统调用标志
- google-apps-script - 如何通过谷歌脚本提取名为范围列号的谷歌工作表?
- python - 如何检查一个或多个特定字符是否为字符串?
- google-cloud-stackdriver - 无法为 Stackdriver Trace 填充方法等
- java - 通过对角线遍历具有左倾对角线部分的二维数组来获取数组列表?
- oauth-2.0 - 如何将 slack 用户与 github 帐户关联?
- c# - 使用 Newtonsoft 获取 JSON 对象的键/值
- xaml - UWP MediaPlayer (Windows.Media.Playback.MediaPlayer) 上的内存泄漏
- java - 如何在 Netbeans IDE 上查看 Hibernate 到文件类别
- react-native - 反应原生推送通知 onRegister 问题