Discussion:
grep / zgrep issue
(too old to reply)
Cleber Baldan Jr
2014-05-20 16:49:56 UTC
Permalink
Hello.

I may have found a bug in the zgrep utility.

When I use this command:
p-***@logbox:/usr/local/apache/logs/prelogs/xxxxxxxx$ find .
-name "abc.log.*" | xargs zgrep -E -i -c -l '(CBL discontinuation)'
./abc.log.2014-05-12.gz
./abc.log.2014-05-13.gz


When I use *-c* it works fine.
But when i add *-l* in the same command line with *-c*, the output won't
have the count of results anymore.
I wanted to have the count of occurences per file

Please, let me know if this is not a bug.

Regards,
Cleber.
Paul Eggert
2014-05-21 00:42:43 UTC
Permalink
Post by Cleber Baldan Jr
I wanted to have the count of occurences per file
I wouldn't consider this to be a bug, since zgrep is behaving just like
grep: -l overrides -c, and if you use both options the -c is ignored.
POSIX allows this behavior for 'grep'.

To get the behavior you want, try 'zgrep -E -i -c -H'. That worked for
me (I'm using GNU grep).

Loading...