[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: plus sign appears not to work as expected
From: |
Bill Gradwohl |
Subject: |
Re: plus sign appears not to work as expected |
Date: |
Wed, 15 Feb 2012 05:16:45 -0600 |
On Tue, Feb 14, 2012 at 4:27 PM, Bob Proulx <address@hidden> wrote:
> Bill Gradwohl wrote:
> > address@hidden wrote:
> > > For grep, you need '^[[:alpha:]]\+'.
> >
> > That backslash did it.
> >
> > Now I'm going into the docs to find where it says I need a backslash for
> > the + but nothing for the *.
>
> It starts with this part:
>
> 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 implementations,
> basic regular expressions are less powerful. The following description
> applies to extended regular expressions; differences for basic regular
> expressions are summarized afterwards.
>
> 'grep' handles basic regular expressions. 'egrep' is the old name for
> 'grep -E' and it handles extended regular expressions. * is a basic
> regular expression and + is an extended regular expression.
>
> GNU grep handles both in a compatible way. If you call 'grep' then it
> handles the basic regular expressions like * and also the extended
> expressions if the extended one is escaped.
>
> If you call it with 'grep' then you should use the basic syntax. But
> the extended is available if it is escaped.
>
> grep '^[[:alpha:]]\+'
>
> If you call it with -E then you get the full extended syntax.
>
> grep -E '^[[:alpha:]]+'
>
> Bob
>
Thanks Bob. I did find the explanation in the docs. Just one more example
of how poorly written the docs are.
So much of grep, bash, and a host of other utilities show their age by the
numerous patches and consequently convoluted docs that support them.
Now I realize why people are heading for things like Python to write
scripts as opposed to bash. Bash has too much baggage, as does grep. Python
starts from a clean slate and can ignore backward compatibility issues as
there are none. It's time to replace grep too to jettison antique idioms
and come up with a cleaner utility that does a modern job.
With new code comes new docs to support it, and less need of this type of
forum.
--
Bill Gradwohl
Re: plus sign appears not to work as expected, arnold, 2012/02/12