Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
what OS are you using? – Aprillion Jun 5 '12 at 8:47
@deathApril,I'm working on linux. – SpawnST Jun 5 '12 at 9:01
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

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

share|improve this answer

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .