I have one zip file. I want to list the contents of another zip file inside this zip file without extracting it. How can I do that ? If it was just a single zip file, it wouldn't be a problem.
unzip -p test.zip testfolder/README.md
Since the unzip
command can't read from standard input, the simple way is of course to use a shell script using temporary files.
As a quick workaround, if you know the name of the zipped ZIP file, you can use the-p
option of the unzip
command and the ability to read file contents from STDIN of an other ZIP program. Most likely Busybox is already installed in your system:
unzip -p outside.zip inside.zip | busybox unzip -l -
As an example:
$ for i in {0..9} ; do touch a/$i ; done
$ for i in {a..i} ; do touch b/$i ; done
$ zip -r b.zip b
$ zip -r a.zip a b.zip
$ unzip -p a.zip b.zip | busybox unzip -l -
Archive: -
Length Date Time Name
--------- ---------- ----- ----
0 08-15-2022 08:47 b/
0 08-15-2022 08:47 b/a
0 08-15-2022 08:47 b/i
[…]