[illumos-Developer] grep -Z etc? (decompress! was: webrev: 650 grep support for -q ...)

Guido Berhoerster guido+illumos.org at berhoerster.name
Sun May 8 08:30:53 PDT 2011


* Attila Fülöp <atf at gesindel.org> [2011-05-06 22:42]:
> Whats wrong with
> find . -type f -exec gzgrep something {} \; -ls
> or
> find . -type f | xargs gzgrep something
> if you want to have the filename prepended on every output line.
> 
> This will work like gnu grep -rZ, or am I overlooking  something?

Both are inherently bad, the former because of performance and
the latter will fail on any special characters such as spaces and
newlines in filenames. You rather want to use:

find . -type f -exec gzgrep something {} +

alternatively using bash or ksh93 (globstar enabled):

gzgrep something **

or with tw:

tw gzgrep something

So grep "-r" really has no benefit at all.
-- 
Guido Berhoerster



More information about the Developer mailing list