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

Is there a command to extract a set of zip files within another zip file and not extracting all of it ? eg: has (,, c_directory, d.txt) How can extract and without extracting c_directory nor d.txt ?

We need to compare the contents in and and look for their differences by comparing their files sizes within them.

thanks all.

share|improve this question

According to man unzip:

   unzip  -  list, test and extract compressed files in a ZIP ar‐

   unzip   [-Z]   [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]]   file[.zip]
   [file(s) ...]  [-x xfile(s) ...] [-d exdir]

          An optional list of archive members  to  be  processed,
          separated  by  spaces.   (VMS  versions  compiled  with
          VMSCLI defined must delimit files with commas  instead.
          See  -v  in OPTIONS below.)  Regular expressions (wild‐
          cards) may be  used  to  match  multiple  members;  see
          above.   Again, be sure to quote expressions that would
          otherwise be expanded or modified by the operating sys‐

In other words, arguments given after the archive name are taken to be the list of files you want extracted:

$ unzip 

If you want to compare the contents of two zip files, you could just list the files in each archive and compare the lists. The options -lqq will cause unzip to list the files in an archive:

 $ unzip -lqq 
  424  2013-03-24 04:39
  424  2013-03-24 04:39
  424  2013-03-24 04:39   d.txt

So, to compare two archives, list the files in each, save into a text file and compare the text files:

$ unzip -lqq | sort > A_files.txt
$ unzip -lqq | sort > D_files.txt
$ diff A_files.txt D_files.txt | grep '<\|>'
<         0  2013-03-24 04:57   only_in_A.txt
>         0  2013-03-24 04:57   only_in_D.txt
share|improve this answer
terdon thanks for responding. what's the standard practice in comparing files in zip files; we have an issue where there were some missing files in a newer zip file but no one caught it. We like to set up a way in script to protect us from this happening again. Do you have a suggestion ? Greatly appreciated – chz Mar 24 '13 at 3:48
@chz see updated answer, just list the contents and compare them using diff. – terdon Mar 24 '13 at 4:00
Hi terdon i tried to accept your answer but I could not update it because of my low score; Thanks for your answers there; I still another question but I'll at another time – chz Mar 25 '13 at 20:11
@chz feel free to ask more questions! Also, feel VERY free not to accept or upvote an answer if it has not helped you. My comment on your other question was not a complaint because you have not accepted my answers, I was just explaining how this site works. Also, you should always be able to accept an answer to your question, it has nothing to do with reputation. See here. When you are a new user you cannot upvote but you can always accept. – terdon Mar 25 '13 at 20:27

You must log in to answer this question.

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