Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Find recursively all archive files of diverse archive formats and search them for file name patterns

I need to search for a file in all zip files in a directory.

Is there a tool like find that be able to search in ZIP files?

I tried this:

find /path/ -iname '*.zip' -print -exec unzip -l {} \; |grep -i '<filename>'

But this only prints path of file in zip file and not the zip file name itself!


share|improve this question

marked as duplicate by Gilles, Ulrich Dangel, Renan, jasonwryan, warl0ck Sep 8 '12 at 1:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

That's why I added the 'echo' to my command. – tripledes Aug 8 '12 at 23:28
up vote 15 down vote accepted


for f in `ls *.zip`; do echo "$f: "; unzip -l $f | grep <file_name>; done
share|improve this answer
Hi; Thanks; Your command makes lots of mass output (because of file date,... that ls prints)! but changing it to this solved the problem: for f in *.zip; do echo "$f: "; unzip -l $f | grep -i <file_name>; done Thank you again. – RYN Aug 8 '12 at 23:31
for f in *.zip; do unzip -l $f | grep <filename> && echo $f; done ... Better this way ? :) – tripledes Aug 8 '12 at 23:34
Yes this is alot better; thanks ;-) – RYN Aug 8 '12 at 23:38
works fine in ubuntu 12, thanks! – yetanothercoder Jun 21 '13 at 15:19
bash: syntax error near unexpected token `;' – mjaggard Sep 29 '15 at 11:24

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