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

86,470

Solution 1

Perreal's answer is right, but I recommend installing atool (look for it in your distribution's package manager). Then, for any kind of archive file, bzip2, gzip, tar... you have just one command to remember :

als archive_name

Solution 2

Use unzip with -l option:

unzip -l file.zip

Solution 3

The less utility is capable of peeking into a zip archive.

Less comes bundled with Unix and there is no need to install als. The output is scrollable (paged) and does not log things to the terminal (unlike unzip -l mentioned in the other answer).

As per https://superuser.com/a/216675/249975,

So simply use less filename.zip

Solution 4

To view the contents of a zipped file without unzip by using this command

unzip -l file.zip

Gor tar files we can use

zcat <archived-file>

Solution 5

zipinfo -1 filename.zip

It returns only filenames, and no more, example (response):

listing.html
my_data.csv
super.txt
Share:
86,470
einpoklum
Author by

einpoklum

Made my way from the Olympus of Complexity Theory, Probabilistic Combinatorics and Property Testing to the down-to-earth domain of Heterogeneous and GPU Computing, and now I'm hoping to bring the gospel of GPU and massive-regularized parallelism to DBMS architectures. I've post-doc'ed at the DB architecture group in CWI Amsterdam to do (some of) that. I subscribe to most of Michael Richter's critique of StackOverflow; you might want to take the time to read it. If you listen closely you can hear me muttering "Why am I not socratic again already?"

Updated on July 05, 2022

Comments

  • einpoklum
    einpoklum almost 2 years

    How can I get the equivalent of an ls of a .zip file (not gzip), without decompressing it, from the command shell? That is, how can I list the different files compressed within my .zip archive?

  • Xavier S.
    Xavier S. about 11 years
    zmore is a file perusal filter for crt viewing of compressed text. If you compress more than one file, it shows the first file only. (perreal's answer is effective that's why i purpose zmore to get more information about compressed file tools)
  • Miklos Aubert
    Miklos Aubert about 11 years
    I'm pretty sure it works with LZMA, yes. Technically, atool is just a clever Perl script that wraps around the existing programs on your system. If you have unrar installed, it will work with rar files, if you have 7zip, atool will know 7z, and so on...
  • einpoklum
    einpoklum about 10 years
    Can you explain in a sentence what lesspipe is about? And provide a link?
  • Joe
    Joe almost 9 years
    Link in original response gets a HTTP 403 for me, but the man page has the info about it. (Run man unzip or visit this.)
  • einpoklum
    einpoklum over 7 years
    This is not an answer to my question; it's about zip, not gzip; and not about cat'ing the contents but listing which files are in the zip archive.
  • msoutopico
    msoutopico over 3 years
    unzip -l file.zip only lists files and folders in the first level, not files inside those folders.
  • perreal
    perreal over 3 years
    that's not correct, at least with the version I'm working with. it does give a recursive listing.
  • manuelpgs
    manuelpgs over 3 years
    Tested on Ubuntu 20.04 and work fine. But does not work On MacOS 10.15.7
  • Peter Moore
    Peter Moore about 3 years
    @perreal what do you mean by recursive list? Do you mean if there are zips inside a zip?
  • perreal
    perreal about 3 years
    I mean files in directories in the zip, @PeterMoore.
  • Peter Moore
    Peter Moore about 3 years
    oh yeah I agree that definitly works for me.