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.

How can I view the files in a zip archive without decompressing it ?

share|improve this question
    
Is it possible to do the same for a regular unix archive? (tar/gzip/bz2/ etc) –  ThorSummoner Oct 17 at 16:59

8 Answers 8

up vote 71 down vote accepted

The less utility is capable of peeking into a zip archive. In fact, if you look at the outputs of unzip -l zipfile and less zipfile, you will find them to be identical.

share|improve this answer
9  
Note, that less zipfile on MacOS-X displays the binary filecontent, so you see a lot of garbage instead of the content of the zip-file. Then you should opt for the ``ùnzip -l zipfile``` –  heiglandreas Jan 25 '13 at 9:59
    
I get slightly more information from unzip compared to less. Just saying. –  matt burns May 7 '13 at 10:57
3  
Equally in Ubuntu (at least in version 12.10) less zipfile displays the binary filecontent as @heiglandreas said. –  user12287 Jul 9 at 15:36
    
@ayaz In what system does less list zipfiles? I see comments telling that it does not work on MAC, Ubuntu, and here I use Debian. Debian also shows binary garbage. –  Dr Beco Aug 12 at 4:38
    
In Ubuntu, try view [zipfile]. –  Samuel Lampa Sep 10 at 16:07

Try unzip -l files.zip | less

Also, See man unzip for more options

share|improve this answer
1  
You can skip the pipe to less command. It is great idea in a big collection of files, though. –  user12287 Jul 9 at 14:39

Please use

vim ZIP_FILE_NAME

for the same. This is a simple and easy to remember one.

share|improve this answer

You can make the zip appear as a directory (in which you use cd, ls, etc.) by mounting it with the fuse-zip virtual filesystem.

mkdir foo.d
fuse-zip foo.zip foo.d
ls foo.d
cat foo.d/README
...
fusermount -u foo.d
rmdir foo.d

Another relevant FUSE filesystem is AVFS. It creates a view of your entire directory hierarchy where all archives have an associated directory (same name with # tacked on at the end) that appears to hold the archive content.

mountavfs
ls ~/.avfs/$PWD/foo.zip\#
cat ~/.avfs/$PWD/foo.zip\#/README
...
umountavfs

Many modern file managers (e.g. Nautilus, Dolphin) show archive contents transparently.

AVFS is read-only. Fuse-zip is read-write, but beware that changes are only written to the zip file at unmount time, so don't start reading the archive expecting it to be modified until fusermount -u returns.

share|improve this answer
    
Nice, Giles. Thanks. Just a quick: can one add files to it by justing "cp"ing to the directory? –  Dr Beco Aug 12 at 4:45
    
@DrBeco With fuse-zip, yes. With avfs, no. –  Gilles Aug 12 at 9:15
    
Thank you Gilles. –  Dr Beco Aug 22 at 23:33

Its actually unzip -l file.zip | grep "search" or if you have a lot of files

for i in `ls *zip`; do 
  unzip -l $i | grep "search"; 
done

Update: Changed from '-p' to '-l' in order to search for files.

share|improve this answer

(yaa) Yet another answer:

Alias this command:

alias vless='/usr/share/vim/vim73/macros/less.sh'

and you can use vless file.zip to take advantage of vi (or vim) less script.

(also good to substitute less, so you can have colors)

share|improve this answer

At least in Ubuntu, the possibly easiest command is:

view [zipfile]

This will open up the file listing in your standard text editor (nano, vim etc).

share|improve this answer

To list zip contents:

zipinfo -1 myzipfile.zip

For detailed output:

zipinfo myzipfile.zip
share|improve this answer

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.