does a zgrep exist? (zgrep <> zcat | grep)
Chris Lewis
clewis at ferret.ocunix.on.ca
Wed Feb 20 05:59:35 AEST 1991
In article <1991Feb15.232854.13378 at robobar.co.uk> ronald at robobar.co.uk (Ronald S H Khoo) writes:
>brister at decwrl.dec.com (James Brister) writes:
>
>> It would be nice to grep through compressed files. Sure, you can do zcat |
>> grep regexp, but then you loose the ability of grep to tell you the
>> filename and/or linenumber of a match.
>Well, if you have it, zcat | grep regexp /dev/stdin would do what you wanted.
>If you can't hack a /dev/stdin driver into your kernel, then as an alternative
>you could modify grep to understand "-" as a filename.
Another approach is some variation (as in, this is untested, but
the algorithm's okay) on:
pat=$1
shift
for i
do
case $i in
*.Z)
zcat $i | grep -n "$pat"
;;
*)
grep -n "$pat" $i
;;
esac | sed -e 's/^/'$i': /'
done
--
Chris Lewis, Phone: (613) 832-0541, Internet: clewis at ferret.ocunix.on.ca
UUCP: uunet!mitel!cunews!latour!ecicrl!clewis; Ferret Mailing List:
(ferret-request at eci386); Psroff (not Adobe Transcript) enquiries:
psroff-request at eci386, current patchlevel is *7*.
More information about the Comp.unix.shell
mailing list