nikosdi
nikosdi

Reputation: 2158

print content of more than one file in a zip archive

I have some zip files that are really large and I want to print them without extracting first. I am using zcat and zless to do that and then I redirect the output to a different application. When my zip file contains more than one text file I receive the following error:

zcat tweets.zip >a
gzip: tweets.zip has more than one entry--rest ignored

How can I do what I want with zip files that contain more than one text file?

Upvotes: 20

Views: 16756

Answers (3)

Emanuel Couto
Emanuel Couto

Reputation: 441

You can do this to output a file without extracting:

$ unzip -p <zip_file> <file_to_print>

For example:

$ unzip -p MyEar.ear META-INF/MANIFEST.MF

As cur4so mentioned you can also list all files using:

$ unzip -l <zip_file>

Upvotes: 31

Mark Adler
Mark Adler

Reputation: 112422

Use the -p option of unzip to pipe the output. Multiple files are concatenated. The -c option does the same thing, but includes the file name in front of each file.

Upvotes: 23

cur4so
cur4so

Reputation: 1820

If you just want to see a list of files in your zip archive use:

unzip -l tweets.zip

if you want to extract just some file:

unzip tweets.zip file-of-interest-as-it-is-pointed-in-the-archive

if you want something else, could you clarify your question?

Upvotes: 1

Related Questions