Search through 2 levels of zip


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Search through 2 levels of zip
# 1  
Old 02-18-2010
Search through 2 levels of zip

Hi guys,

I know I'm missing something simple here.

We have about 500 zipped files in a directory which contain more zip files and within those I need to find a file without unzipping everything.

I know I can use zipinfo which I'm trying to create a for loop to go through the files and search but what I have so far only looks in the first level of the zip I need to go down the next level to find the filename. Below is what I've tried

Code:
for f in *.zip;do zipinfo $f | grep '<filename>';done

Thanks in advance

Pete

Last edited by zaxxon; 02-18-2010 at 08:15 AM.. Reason: use code tags please
# 2  
Old 02-18-2010
Not sure if I understood you correctly; I just checked it out - it display contents of subdirs with several levels:

Code:
$> zip -r my.zip *
  adding: a (stored 0%)
  adding: b (stored 0%)
  adding: dir1/ (stored 0%)
  adding: dir1/d (stored 0%)
  adding: dir1/c (stored 0%)
  adding: dir1/dir2/ (stored 0%)
  adding: dir1/dir2/f (stored 0%)
  adding: dir1/dir2/dir3/ (stored 0%)
  adding: dir1/dir2/dir3/h (stored 0%)
  adding: dir1/dir2/dir3/g (stored 0%)
  adding: dir1/dir2/e (stored 0%)
$> zipinfo my.zip
Archive:  my.zip   1428 bytes   11 files
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:19 a
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:19 b
drwxr-xr-x  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:20 dir1/d
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:20 dir1/c
drwxr-xr-x  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/f
drwxr-xr-x  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/dir3/
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/dir3/h
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/dir3/g
-rw-r--r--  2.3 unx        0 bx stor 18-Feb-10 13:21 dir1/dir2/e
11 files, 0 bytes uncompressed, 0 bytes compressed:  0.0%

With your for loop seems nothing wrong too. Is it just a guess it is not showing deeper level contents or can you reproduce it on for example one of those 500 zip files?
# 3  
Old 02-18-2010
Hi Zaxxon, thanks for responding

We have files which come in and get processed these are then zipped, then after 2 weeks are zipped again to archive off. I need to be able to search in the archived files (compressed twice) to find files.

The for loop does work but only on zip files which have been compressed once, the archive ones have been zipped a second time.

Hope that makes sense.

Pete
# 4  
Old 02-19-2010
Ah ok, now I understand - afaik there is no option (and no tool that comes to my mind) to get any contents of subsequent zipped archives.

Maybe it is an option to change handling of those archives, ie. that you only compress the archive that contains them all and the single former archives are just tar archives, for example.

If it is an option for you, usually archivers like tar and compression utilities like gzip bzip2, zip etc. have or should have an append option you could use so that still only the big large archive containing all others is compressed by some tool which still provides the ability to search content listings.
# 5  
Old 02-19-2010
Yeah I know what your saying

Unfortunately the files are moved between servers at certain times by cron to be processed, so it's not an option to roll them up into one file as it time critical.

Hmm must be a way of doing this
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

2. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

3. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

4. UNIX for Dummies Questions & Answers

search for a string in zip file

Hi, I know gzcat helps grep for a string inside a file that has been zipped using gzip command. However, how can the same be achieved for files zipped using zip command and any other compression commands you may know off. Thanks, Mohtashim (5 Replies)
Discussion started by: mohtashims
5 Replies

5. Solaris

Levels of support

Hello, I have a simple question because I can not find the information at oracle.com I want to buy support for OS Solaris and Servers hardware. I need information what are the levels of support and how much they cost? I need a help. Have a nice day (3 Replies)
Discussion started by: bieszczaders
3 Replies

6. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies

7. UNIX for Dummies Questions & Answers

How to search for a string within a zip

Hi Guys, We have some really large zip files containing hundreds of files, we need to search within these compressed files for a string in the filename eg ABC if found then extract the file from the zip ? I've searched for a long time but no joy Any help really appreciated Thanks ... (6 Replies)
Discussion started by: petef
6 Replies

8. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies

9. Solaris

Init levels

I have a problem, i dont know if its a normal behaviour or not, i can go to a lower init level, but i cant go to a higher one again, for instance i can run the command init 2 while im at init 3 and when i do who -r i find myself go down to 2 but if i type init 3 and wait im still finding myself in... (1 Reply)
Discussion started by: XP_2600
1 Replies

10. Solaris

RAID Levels

hi, what are the RAID Levels followed for various File systems ? thanks (3 Replies)
Discussion started by: sol8admin
3 Replies
Login or Register to Ask a Question