home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] does current gnu grep support EREs out of the box?

  • Subject: Re: [OCLUG-Tech] does current gnu grep support EREs out of the box?
  • From: "Brenda J. Butler" <bjb [ at ] sourcerer [ dot ] ca>
  • Date: Wed, 7 Mar 2018 14:57:46 -0500
On Tue, Mar 06, 2018 at 05:35:55AM -0500, Robert P. J. Day wrote:
> 
>   course i taught last week provided courseware that distinguished
> between grep's basic RE support and "extended" RE support, which
> surprised me as, on my fedora 27 system, the man page for grep has the
> following snippets:
> 
> "In addition, the variant programs egrep and fgrep are the same as
> grep -E and grep -F, respectively.  These variants are deprecated, but
> are provided for backward compatibility."
> 
>   also, further down:
> 
> "grep understands three different versions of regular expression
> syntax: “basic” (BRE), “extended” (ERE) and “perl” (PCRE).  In GNU
> grep there is no difference in available functionality between basic
> and extended syntaxes."

I think what it might be saying is that you can find all the same
patterns, but the syntax will be different for BRE and ERE.

It is not the case that you will have to learn two syntaxes - you can learn
either one and it is sufficiently powerful to do everything the other
one can do.  Unlike the old days, when ERE really was an extension
over what BRE could do.  Seems BRE has been "extended" ...

> "grep understands three different versions of regular expression
> syntax: ???basic??? (BRE), ???extended??? (ERE) and ???perl??? (PCRE).  In GNU
> grep there is no difference in available functionality between basic
> and extended syntaxes."

The functionality is the same for BRE and ERE (according to man page, I haven't
tested it), but the syntax is different and you have to tell grep which you
are using with the -E and -F flags.  -F is for "fixed string", last I heard.
no-flag means Basic, and -E means Extended and -F means 'just looking for this
literal string, no need to interpret any RE special chars at all'.

>   that *seems* pretty clear, but i just want to confirm that, in gnu
> grep these days, the extended REs are now available automatically and
> don't require options like they used to. thoughts?

bjb