zgrep cannot find all matches

$ cat 1.csv
abc in csv
$ cat 1.mnf
abc in mnf
$ zip 1.zip 1.csv 1.mnf
  adding: 1.csv (stored 0%)
  adding: 1.mnf (stored 0%)
$ zgrep abc 1.zip
abc in csv

How come zgrep cannot find "abc in mnf"?
Thanks in advance.

this very strange i don't what is reason for this....

 zcat 1.zip
abc in csv
zcat: 1.zip has more than one entry--rest ignored
$
1 Like

Hi.

On my system:

OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny) 

The command zgrep is a shell script:

% file /bin/zgrep
/bin/zgrep: POSIX shell script text executable

It calls gzip. In the man page for gzip:

       Files created by zip can be uncompressed by gzip only if they have a
       single member compressed with the 'deflation' method. This feature is
       only intended to help conversion of tar.zip files to the tar.gz format.
       To extract a zip file with a single member, use a command like gunzip
       <foo.zip or gunzip -S .zip foo.zip.  To extract zip files with several
       members, use unzip instead of gunzip.

-- excerpt from man gzip

The man pages are your firends.

Best wishes ... cheers, drl

1 Like

Understood and thanks.
But how do I make zgrep call unzip instead of gzip?

I know this is not the efficient way of doing this. You might get good solution here from the gurus...

lets try this..

cat `unzip 1.zip | grep "extracting:" | awk '{ print $2 }'`

You could also do like this.

unzip -p 1.zip | grep ...
1 Like