Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

diff files inside of zip without extracting it [closed]

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?

Thanks.

like image 425
Gum Bi Avatar asked Feb 23 '16 15:02

Gum Bi


People also ask

How can I view a zip file without extracting it?

Viewing Zip File Contents Without Extracting To view a ZIP file's contents, run the unzip command to list ( -l ) the zip file's ( newdir. zip ) contents without extracting them.

How can I edit a zip file without extracting it?

open archive in archive manager. open text file in KDE gui editor. save text file and system ask you to refresh archive - click yes.


1 Answers

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); }

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.

like image 140
Mark Howard Avatar answered Oct 21 '22 00:10

Mark Howard