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.

  • 2
  • @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. Apr 21, 2017 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, 2017 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. Apr 21, 2017 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, 2017 at 20:38

8 Answers 8


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

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

unzip -p archive.zip file1.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.

Edit: Changed this answer to use -p instead of -c. -p extracts the file byte-for-byte, while -c prints the filename and may do EOL conversion. Also, unzip -p lets you extract multiple files, but it does not output in the order given like cat does.

  • 10
    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, 2013 at 20:30
  • 1
    bzcat for viewing the contents of bz2 files without having to uncompress them first...
    – Justin E
    Nov 12, 2014 at 19:37
  • 5
    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 Mar 24, 2015 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). Jan 4, 2017 at 11:57
  • 3
    unzip -p ... will cat the contents of the files in the archive without inserting the file names into the output stream
    – jvd10
    May 24, 2019 at 21:19

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


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

vim archive.zip

BTW: here is the same question.


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


A better way is just using zmore or zless, for example

zmore syslog.2.gz
  • this is for gzip compression, not zip as per the OP request Feb 27 at 11:05

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, 2019 at 11:16
  • Thanks for the clarification, @karel Apr 25, 2019 at 11:21
  • I think that what you're really trying to do would be the same as danielcraigie's answer.
    – karel
    Apr 25, 2019 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)

  • 1
    Yes, but you can extract to stdout and pipe right into a pager. Jan 4, 2017 at 12:08
  • 1
    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) Aug 21, 2018 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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