I have a set of nested zip files and I need to list the file names without extracting the archives. For example:
- Zip1.zip
- text1
- text2
- Zip2.zip
- Sample1
- Sample2
with some shell scripting should result in a list such as
Zip1.zip
Zip1.zip/text1
Zip1.zip/text2
Zip1.zip/Zip2.zip/Sample1
Zip1.zip/Zip2.zip/Sample2
Best Answer
The unzip -p flag will pipe the uncompressed data to stdout. Unfortunately the
unzip
program doesn't have an option to read from stdin for some reason. Adapting the python one liner from this answer to a similar question does the trick.eg:
Added: The Java jar tool can read from stdin. stolen from this answer.
eg:
output:
original zip file:
Found the relevant Serverfault thread from your - comment.
This isn't a shell script, but it does what was suggested in the original question: