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 October 2014, 10:32 PM EDT
Location: NM
Posts: 10,236
Thanks: 281
Thanked 802 Times in 746 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 October 2014, 10:32 PM EDT
Location: NM
Posts: 10,236
Thanks: 281
Thanked 802 Times in 746 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: 17 October 2014, 11:59 AM EDT
Location: Galactic Empire
Posts: 3,387
Thanks: 235
Thanked 1,209 Times in 1,135 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 07: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: 16 October 2014, 8:14 PM EDT
Posts: 2,927
Thanks: 110
Thanked 929 Times in 869 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 02:41 AM
Unzipping windows zip files on Sun sparc workstation achartley UNIX for Dummies Questions & Answers 4 10-10-2010 08:42 PM
Unzipping latest zip file by name. mrwatkin Shell Programming and Scripting 3 08-07-2009 11:04 AM
Alter zip file without unzipping _prasad Solaris 1 12-24-2008 09:07 AM
unzipping .zip file on HP and Solaris dangral UNIX for Dummies Questions & Answers 9 04-17-2005 11:44 AM



All times are GMT -4. The time now is 05:39 AM.