How can I read the contents of a particular file in an archive without extracting the .zip it is contained within? I'm using the Linux command line.

An earlier question asks about viewing the directory of the archive. But for me it is not enough to see just a list of the files in the archive, I need to see the contents of a file in the archive.

  • 1
  • @fixer1234 (and others): The linked question asks, “How can I view the files in a ZIP archive?” AFAIC, that’s the same question as “How can I see the contents of a file …?” It’s unfortunate that many of the people who answered that question interpreted it as “How can I view the directory of the archive?” However, Gilles’s answer (naturally) and Rajasekhar Tolety’s answer (apparently) to that question provide answers to this question. – Scott Apr 21 '17 at 19:42
  • 1
    @Scott, maybe we should figure out how to merge the two questions so both topics are covered in one, or refocus the other to clearly be about the directory and then move answers between both places to match the questions. Right now, both are a mishmash. – fixer1234 Apr 21 '17 at 20:12
  • @fixer1234: I agree, up to a point. The moderators are always telling us that duplicates are a good thing, because they provide a greater surface of exposure to the search engines (i.e., more chances that a search will find one of the questions). But there’s the rub: if a user finds one of the questions, and the linkage isn’t obvious (and nobody looks at the lists of “Linked” and “Related” questions — at least not random followers of search results), then the user has found only a fraction of the answers. DavidPostill cast the final vote to reopen this question; maybe you should talk to him. – Scott Apr 21 '17 at 20:26
  • @Scott — Given that the question asker marked the “How can I view the directory of the archive?” answer as accepted, I have to think that was likely the intent of the question. It is, unfortunately, ambiguously phrased such that it could mean either interpretation. – M. Justin Apr 21 '17 at 20:38

unzip -l archive.zip lists the contents of a ZIP archive to ensure your file is inside.

Use the -c option to write the contents of named files to stdout (screen) without having to uncompress the entire archive.

unzip -c archive.zip file1.txt file2.txt | less

For this kind of operation I always pipe the output to less, otherwise the whole file goes flying up the screen before you can read it.

BTW zcat is great for viewing the contents of .gz files without having to uncompress them first.

  • 7
    At least in Ubuntu, less is somehow configured to do this by default - so less archive.zip actually shows the list of files. – aviv Mar 24 '13 at 20:30
  • 1
    bzcat for viewing the contents of bz2 files without having to uncompress them first... – Justin E Nov 12 '14 at 19:37
  • 2
    unzip -c also shows the file name and some extra messages (sending them to stdout). Using -p instead only sends the file in binary format. That's more useful for piping – Juan Calero Mar 24 '15 at 10:02
  • With your $LESSOPEN set to lesspipe, you can just less foo.gz to view the decompressed contents. (@aviv: this is the same thing that enables less foo.zip to pipe unzip -l foo.zip into itself). – Peter Cordes Jan 4 '17 at 11:57
  • unzip -c archive.zip '*' | less does what I was looking for: cat the contents of the zip archive. – Peter Cordes Jan 4 '17 at 11:59

zipinfo is another tool you might use, this is useful if you're on a locked-down system where unzip is not allowed.


If you're just looking to view images inside the archives, you can use Comix or newer MComix to see images inside .zip, .rar, .cbr, and .cbz files without extracting.


Start Emacs in command-line and open your zip files with Zip-Archive mode. Without any Emacs/elisp tuning (new users generally fear about), you will see file details like from zipinfo: modes, length, date, time

Then, you will be able to open files in buffers and even save your changes back to archive, with standard shortcuts:

  • Enter on a file name in list to open it
  • Edit and save with Ctrl-x Ctrl-s
  • Kill buffer Ctrl-k to go back to archive buffer and go on

When in Zip-Archive buffer, use Ctrl-h m to get all shortcuts available in Help View.

Hope this may lead you to discover Emacs awesome features


You can use vim to list content of the zip/rar/tar archive:

vim archive.zip

BTW: here is the same question.


I've found less archive.zip to be the easiest way to do this.

  • 2
    less archive.zip doesn't show the contents of a zipped file, it only shows the contents of a zipped archive. – karel Apr 25 at 11:16
  • Thanks for the clarification, @karel – RobertMyles Apr 25 at 11:21
  • I think that what you're really trying to do would be the same as danielcraigie's answer. – karel Apr 25 at 11:22

If the file is included in zip archive, that you need to extract only that file from archive (may depend on archive type, some archives can't extract files seperately)

  • Yes, but you can extract to stdout and pipe right into a pager. – Peter Cordes Jan 4 '17 at 12:08
  • This is not a technical answer, it is more likely from a politician or a solicitor. Please be more specific! (show the command for example) – Hola Soy Edu Feliz Navidad Aug 21 '18 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.