# Linux – Read the contents of a zipped file without extraction

linuxzip

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.

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.
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.