Finding a text file from a group of zip files without unzipping | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-19-2012
karthikk0508 karthikk0508 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 12 June 2014, 11:24 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old 11-19-2012
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 19 December 2014, 11:40 PM EST
Location: NM
Posts: 10,312
Thanks: 297
Thanked 822 Times in 764 Posts
You have to open zip files and read what amounts to a directory of the file. There is no other way.
Sponsored Links
    #3  
Old 11-19-2012
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 19 December 2014, 11:40 PM EST
Location: NM
Posts: 10,312
Thanks: 297
Thanked 822 Times in 764 Posts
Forgot to add:


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

    #4  
Old 11-19-2012
karthikk0508 karthikk0508 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 12 June 2014, 11:24 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
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..
Sponsored Links
    #5  
Old 11-19-2012
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 19 December 2014, 6:33 PM EST
Location: Galactic Empire
Posts: 3,395
Thanks: 240
Thanked 1,211 Times in 1,137 Posts
Try this:-

Code:
unzip -l *.zip | grep max1157.txt

To get zip file name:-

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


Last edited by Yoda; 11-19-2012 at 08:10 PM..
Sponsored Links
    #6  
Old 11-19-2012
karthikk0508 karthikk0508 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 12 June 2014, 11:24 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you Jim...Will give it a try and will let you know Thank you very much for the quick response appreciate your help.
Sponsored Links
    #7  
Old 11-19-2012
Chubler_XL's Avatar
Chubler_XL Chubler_XL is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 18 December 2014, 5:15 PM EST
Posts: 3,051
Thanks: 114
Thanked 984 Times in 921 Posts
Try this:


Code:
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
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Group files and zip nightrider Shell Programming and Scripting 7 12-28-2011 03:41 AM
Unzipping windows zip files on Sun sparc workstation achartley UNIX for Dummies Questions & Answers 4 10-10-2010 09:42 PM
Unzipping latest zip file by name. mrwatkin Shell Programming and Scripting 3 08-07-2009 12:04 PM
Alter zip file without unzipping _prasad Solaris 1 12-24-2008 10:07 AM
unzipping .zip file on HP and Solaris dangral UNIX for Dummies Questions & Answers 9 04-17-2005 12:44 PM



All times are GMT -4. The time now is 03:23 PM.