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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 11-19-2012
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 31 March 2015, 10:49 PM EDT
Location: NM
Posts: 10,411
Thanks: 325
Thanked 854 Times in 793 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 Unix and Linux 11-19-2012
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 31 March 2015, 10:49 PM EDT
Location: NM
Posts: 10,411
Thanks: 325
Thanked 854 Times in 793 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 Unix and Linux 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 Unix and Linux 11-19-2012
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 30 March 2015, 11:20 AM EDT
Location: Galactic Empire
Posts: 3,401
Thanks: 240
Thanked 1,215 Times in 1,141 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 Unix and Linux 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 Unix and Linux 11-19-2012
Chubler_XL's Unix or Linux Image
Chubler_XL Chubler_XL is offline Forum Staff  
Moderator
 
Join Date: Oct 2010
Last Activity: 31 March 2015, 6:29 PM EDT
Posts: 3,124
Thanks: 121
Thanked 1,024 Times in 958 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 11:10 PM.