zip内的差异文件而不解压缩 [英] diff files inside of zip without extracting it
问题描述
有什么方法可以对两个zip中的两个文件执行差异运算而不提取它们吗?如果不是-是否有其他解决方法可以在不进行提取的情况下进行比较?
Is there any way to perform diff operetion on two files in two zips without extracting them? If not - any other workaround to compare them without extracting?
谢谢.
推荐答案
结合到目前为止的答复,以下bash函数将比较zip文件中的文件列表.清单中包含详细的输出( unzip -v
),因此可以比较校验和.输出按文件名( sort -k8
)排序,以允许并排比较,而diff输出扩展( W200
),因此文件名在侧视图中可见.
Combining the responses so far, the following bash function will compare the file listings from the zip files. The listings include verbose output (unzip -v
), so checksums can be compared. Output is sorted by filename (sort -k8
) to allow side by side comparison and the diff output expanded (W200
) so the filenames are visible int he side by side view.
function zipdiff() { diff -W200 -y <(unzip -vql $1 | sort -k8) <(unzip -vql $2 | sort -k8); }
可以将其添加到您的〜/.bashrc
文件中,以便从任何控制台使用.它可以与 zipdiff a.zip b.zip
一起使用.将输出减少到少或重定向到文件对于大型zip文件很有帮助.
This can be added to your ~/.bashrc
file to be used from any console. It can be used with zipdiff a.zip b.zip
. Piping the output to less or redirecting to a file is helpful for large zip files.
这篇关于zip内的差异文件而不解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!