[KLUG Members] Re: grep, egrep, fgrep

members@kalamazoolinux.org members@kalamazoolinux.org
Thu, 6 May 2004 10:29:14 -0400


On Thu, May 06, 2004 at 10:04:13AM -0400, John Pesce was only escaped
   alone to tell thee:

> Can anyone explain why there are still three different greps?

 grep - the standard grep
egrep - used to be a separate binary, with support for extensions to
        regular expressions (also -E)
fgrep - for multiline patterns:

$ fgrep 'blah
howdy' filename.txt

This will match any two lines in the file with blah on the first line
and howdy in the second (also -F).

It's also worth noting that -P enables the use of Perl-compatible regexes.

These all used to be separate binaries with these enhanced functions.
This was back in the days when AT&T and BSD were fighting over source
code copyrights.  The FSF wrote them all into one binary that checks its
own name when started for clues on how to behave.

-- 
The undesirable classes do not liquidate themselves. -- Joseph Stalin