Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted
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.

share|improve this answer
add comment

you can try this one:

zipinfo -1 zip.zip | grep '\(/\|^\)*.\.doc$'
share|improve this answer
add comment

If you mount the archive as a directory, you can use the usual commands without having to worry about the fact that the files are inside an archive.

The AVFS filesystem presents a view of the filesystem where every archive file /path/to/foo.zip is accessible as a directory ~/.avfs/path/to/foo.zip#. AVFS provides read-only access to most common archive file formats. Run the command

mountavfs

once after each reboot (if you ever want to unmount ~/.avfs, run fusermount -u ~/.avfs).

After that, the usual commands will work:

cd ~/.avfs$PWD
find zip.zip\# -name '*.doc'

or

ls ~/.avfs$PWD/zip.zip\#/**/*.doc
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.