bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: GREP (GNU grep) 2.5


From: Bob Proulx
Subject: Re: GREP (GNU grep) 2.5
Date: Sun, 5 Dec 2004 10:23:17 -0700
User-agent: Mutt/1.5.6+20040907i

James L. Fitzgerald wrote:
> Though the documentation available through "man grep" reads,
> regarding "Regular Expressions":
> [quoting]
> grep understands two different versions of regular expression
> syntax: "basic" and "extended." In GNU grep, there is no difference
> in available functionality using either syntax. [endquote]

Hm...  I could be convinced that documentation is misleading. :-)  These
two following are equivalent.  The functionality available is the
same.  But you have to specify it differently.

  echo foo | grep 'f\|b'
  echo foo | grep -E 'f|b'

> However, I have found that I can make the "OR" operator ("|") work
> in a regular expression only if I invoke the -E command line option.

That is correct.  You need the -E option to put grep into 'egrep' mode
using extended regular expressions.

The traditional unix command was 'egrep' and it used extended regular
expressions.  This has been standardized into 'grep -E'.  GNU grep
(and sed and others) extends the basic regular expressions in the case
that the meta character is quoted, turning on the extended
functionality in that case since it is an unused sequence in basic
regular expressions.

It is better and more portable to use the 'grep -E' syntax when
desiring to use extended regular expressions.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]