bug-grep
[Top][All Lists]
Advanced

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

Re: Erroneous claim in grep man page


From: Tony Abou-Assaleh
Subject: Re: Erroneous claim in grep man page
Date: Fri, 8 Aug 2008 11:58:32 -0300 (ADT)

On Fri, 8 Aug 2008, Francis Litterio wrote:

> The grep/egrep man page says this:
>
>   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.  In other implementa-
>   tions, basic regular expressions are less powerful.
>
> But I see this behavior with grep 2.5.1:
>
>       $ echo foobar | grep 'fo+bar'
>       $ echo foobar | egrep 'fo+bar'
>       foobar
>
> So the claim in the man page that "there is no difference in available
> functionality using either syntax", doesn't seem to be true.

Francis,

The main difference between basic and extended regular expressions in GNU
grep is that only . and * have a special meaning in basic regular
expression, all other characters must be escaped before they become
special. In the extended regexp, it's the other way around - many
characters such as + are special and must be escaped to become nonspecial.

$ echo foobar | grep 'fo+bar'
$ echo foobar | grep 'fo\+bar'
foobar
$ echo foobar | egrep 'fo\+bar'
$ echo foobar | egrep 'fo+bar'
foobar

Cheers,

TAA

-- 
Tony Abou-Assaleh
Email:    address@hidden
Web site: http://tony.abou-assaleh.net






reply via email to

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