Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a big zip file and I want to know what it's contain. I know I can run:

zipinfo file.zip

but the output is too verbose and there are a lot of files in the sub-directories.

I want to see a list of the files in the top level.

Example

If the normal output is:

-sh-3.2$ zipinfo file.zip
Archive:  file.zip   999999999 bytes   99999 files
-rw-r--r--  2.3 unx     3894 tx defN  3-Jul-11 13:11 file1
drwxr-xr-x  2.3 unx        0 bx stor 23-Feb-12 21:00 dir1/
-rw-r--r--  2.3 unx      269 tx defN 23-Oct-11 14:34 dir1/file2
drwxr-xr-x  2.3 unx        0 bx stor 25-Sep-11 03:53 dir1/subdir1/
...
drwxr-xr-x  2.3 unx        0 bx stor 23-Feb-12 21:00 dir2/
...

I want a command that will output:

-sh-3.2$  <answer>
Archive:  file.zip   999999999 bytes   99999 files
-rw-r--r--  2.3 unx     3894 tx defN  3-Jul-11 13:11 file1
drwxr-xr-x  2.3 unx        0 bx stor 23-Feb-12 21:00 dir1/
drwxr-xr-x  2.3 unx        0 bx stor 23-Feb-12 21:00 dir2/
drwxr-xr-x  2.3 unx        0 bx stor 23-Feb-12 21:00 dir3/
...
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can filter the output with grep. Here I'm telling grep to hide all rows that contain a slash '/' and anything after the slash:

zipinfo file.zip | grep -v "/."
share|improve this answer
    
wow! thank you for your fast answer :) –  Sapir Apr 20 '12 at 15:34

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.