[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Why grep still exists?



On Tue, May 27, 2003 at 07:39:51AM +0800, jqdkf@zju.edu.cn wrote:
> I'm just wondering why grep still exists in every distribution of UNIX
> or UNIX like system. As egrep can support a full featured regular
> expression, it is much more powerful than grep. Is it only for backport
> support?

Sometimes grep is more useful, or at least more concise. For example,
egrep's man page notes that "Traditional egrep did not support the {
metacharacter, and some egrep implementations support \{ instead, so
portable scripts should avoid { in egrep patterns and should use [{] to
match a literal {". Also, if you're trying to match literal characters
in [?+{|()] then you don't have to backslash them for grep. If you're
not worried about the portability issue above, then you *can* do
everything in egrep that you can do in grep, but you could also do it in
perl; the fact that a more powerful tool exists doesn't necessarily mean
it's a good idea to remove the simpler tool.

In addition, a fantastically large base of existing software requires
grep. Even if it were desirable to remove it, which I don't think it is,
compatibility issues would make it impossible.

In any case, grep, egrep, and fgrep are all just the same program with
different default options, so it's not a big deal to keep them all.

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: