Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to check a lot of zip files to make sure it contains the right directories. what I've done is looping all the zip files then use unzip to uncompress and check it one by one.But the CPU and time consuming problem come up.And I believe the situation would be better if it's done without uncompressing stuff.So is there any other more effective solution for this work?

share|improve this question
1  
what OS are you using? –  deathApril Jun 5 '12 at 8:47
    
@deathApril,I'm working on linux. –  SpawnST Jun 5 '12 at 9:01
add comment

3 Answers 3

up vote 5 down vote accepted

Don't do an actual unzip (uncompress) just list the contents on the zip file. Not sure which unzip binary you are using but the man page for unzip have the list option:

unzip -l

From the zip file format specification it looks like it can then just skip to the next entry without doing any uncompressing.

share|improve this answer
    
the answer helps a lot.thanks. –  SpawnST Jun 5 '12 at 9:15
add comment

You can use zipinfo to list a zip file contents without extracting/uncompressing its data.

share|improve this answer
add comment

In cases where such tricks don't work, unzip to /dev/null and redirect the standard output to file. This won't save you the CPU work, but it will save you the disk I/O associated with actually writing out all the files. The redirected standard output will still list the unzipped filenames.

share|improve this answer
    
How do you unzip to /dev/null (outside -l which doesn't unzip at all) ? According to its documentation, unzip either extracts files in the current directory, the directory specified by the -d option, or to stdout with the -c option. None of these allow redirecting the files to a device and the filenames to stdout. –  jlliagre Jun 5 '12 at 19:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.