[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep -e '\(a\)\1' -e '\(b\)\1'
From: |
Tapani Tarvainen |
Subject: |
Re: grep -e '\(a\)\1' -e '\(b\)\1' |
Date: |
16 Feb 2001 19:38:51 +0200 |
address@hidden (Hans-Bernhard Broeker) writes:
> Tapani Tarvainen <address@hidden> wrote:
>
> > The grep command in the subject line doesn't work
> > correctly with Gnu grep 2.4: it fails to match 'bb'.
>
> Looks like pilot error, to me:
>
> $ echo bb | grep -e '\(a\)\1' -e '\(b\)\2'
> bb
That's not the way it should work: multiple -e arguments
should be treated as independent patterns and back references
should not refer to previous ones.
At least that's how I read POSIX.2, and that's the way
HP-UX grep works.
Same applies when multiple patterns are separated by newline:
grep '\(a\)\1
\(b\)\1'
should match aa and bb, not ba.
Incidentally,
echo ba | grep -e '\(a\)\1' -e '\(b\)\1'
doesn't print anything either.
> > Same problem with egrep '(a)\1|(b)\1'.
>
> $ echo bb | egrep '(a)\1|(b)\2'
> bb
There you are correct, now they are in the same pattern
(and that's a nonportable Gnu extension anyway).
But again,
echo ba | egrep '(a)\1|(b)\1'
doesn't print ba either.