The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-30-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
1:
Code:
for file in *.zip ; do if unzip -qq -l $file | awk '{ print $4 }' | grep filename_to_look_for > /dev/null ; then echo $file ; fi ; done
2:
Code:
for file in *.zip ; do if unzip -p $file | strings | grep searchstring > /dev/null ; then echo $file ; fi ; done
If you want to get the file within the zip, it'll be a slower search but you can do this:
Code:
#!/bin/su
$searchstring=$1
for zipfile in *.zip
do
  unzip -qq -l $zipfile | awk '{ print $4 }' | while read file
  do
    if unzip -p $zipfile $file | grep $searchstring > /dev/null
    then
      echo "$zipfile / $file"
    fi
  done
done