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: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Tue, 6 Mar 2018 06:24:50 -0500 (EST)
On Tue, 6 Mar 2018, Richard Guy Briggs wrote:

> On 2018-03-06 05:35, 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."
> >
> >   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?
>
> I don't remember which system this was on, but was a bit surprised
> at one point when I was using extended regex syntax with grep
> without the -E flag and it just worked.  In the past I had to invoke
> the flag to get that functionality. I don't remember the details of
> which distro it was or what extended syntax feature I was using.

  just tested and, apparently, you still need to (at least on fedora)
mention that you want EREs. example:

  $ grep "(ibm|oracle)" /etc/services
  $

  $ grep -E "(ibm|oracle)" /etc/services
  prospero-np     1525/tcp        orasrv          # Prospero
  non-privileged/oracle
  ibm-app         385/tcp                 # IBM Application
  ibm-app         385/udp                 # IBM Application
  ibm-db2         523/tcp                 # IBM-DB2
  ibm-db2         523/udp                 # IBM-DB2
  ... etc etc ...
  $

the top part of the man page is apparently simply saying that "egrep"
and "fgrep" are deprecated, and you should use "grep -E" and "grep -F"
instead. the man page is annoyingly vague on support for EREs, but i
just now read the bottom of that page:

   Full Documentation
       A complete manual ⟨http://www.gnu.org/software/grep/manual/⟩ is
       available.  If the info and grep programs are properly installed
       at your site, the command

              info grep

       should give you access to the complete manual.

   NOTES
       This man page is maintained only fitfully; the full documentation
       is often more up-to-date.

so now i'm aware that the man page for grep could be unreliable and
the info page is the go-to source.

rday