How to list all *.doc files in a Zip archive, including files in subdirectories

recursivewildcardszip

I have Zip files, that might look like this:

$ zipinfo -1 zip.zip
doc.doc
dotx.dotx
xls.xls
ppt.ppt
txt.txt
c.c
subdir/subdir2/doc.doc
subdir/xls.xls
subdir/ppt.ppt
subdir/c.c
subdir/txt.txt
subdir/subdir2/
subdir/

I want it to print all the *.doc files, but zipinfo -1 zip.zip *.doc only prints the .doc files in the root directory of the Zip file. How can I print all the .doc files, in all the subdirectories?

Best Answer

zipinfo -1 zip.zip '*.doc'

works for me, displaying all files in sub-directories. I think you are forgetting the quotes around the *.doc. Without the quotes, the *.doc expands to all .doc files in the current directory, and then that is passed to zipinfo as the search pattern. So if you have an unzipped version of the archive present in the local directory, then the command will only show top-level .doc files.

With quotes, the argument is protected from the shell, so the wildcard actually makes it to zipinfo successfully.

Related Question