Finding a text file from a group of zip files without unzipping

HI ,
There are more than 100 zip files in a directory and i wanted to see if there is a max1157.txt file in any of the zip files without actually unzipping them. Could you please help. Thanks in Advance.

Karthik.

You have to open zip files and read what amounts to a directory of the file. There is no other way.

Forgot to add:

for fname in *.zip
do
   zip -l  | grep -q -F 'max1157.txt'  && echo " $fname  has my file"
done

i used a zipgrep command. But i think i had to install the utility to actually make it work. I m fairly new to Solaris administration actually. So i m seeking some help here. When i unzip the file in windows it actually has lot of files. And there are about 50 zip files and i had to unzip each of them..

Try this:-

unzip -l *.zip | grep max1157.txt

To get zip file name:-

for zip_file in *.zip
do
   if [ $( unzip -l $zip_file | grep -c max1157.txt ) -ne 0 ]
   then
         echo $zip_file
   fi
done

Thank you Jim...Will give it a try and will let you know Thank you very much for the quick response appreciate your help.

Try this:

for file in *.zip
do
    zipinfo -1 $file | grep -q '^max1157\.txt$' && echo $file
done

Edit: oops seems others have posted very similar solutions while I was testing this