PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > grep: BRE with caret
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

grep: BRE with caret

Réponse
 
LinkBack Outils de la discussion
Vieux 21/08/2006, 16h00   #1
Daniel Mentz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut grep: BRE with caret

I have some problems with grep and BRE (Basic Regular Expressions).
According to my documentation, a caret which is not the first character in
a BRE matches a literal caret.

The following command should find all lines containing "xx^x":
grep "xx^x"

But it doesn't match lines containing "xx^x".

Whereas
grep ".x^x"
works fine. It matches "xx^x"

Could somebody explain to me why the first command isn't working as
expected.
I'm using grep (GNU grep) 2.5.1

Thanks for your
Daniel Mentz
  Réponse avec citation
Vieux 21/08/2006, 16h22   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

On Mon, 21 Aug 2006 17:00:09 +0200, Daniel Mentz
<usenet@fire-of-desire.de> wrote:
> I have some problems with grep and BRE (Basic Regular Expressions).
> According to my documentation, a caret which is not the first character in
> a BRE matches a literal caret.
>
> The following command should find all lines containing "xx^x":
> grep "xx^x"
>
> But it doesn't match lines containing "xx^x".
>
> Whereas
> grep ".x^x"
> works fine. It matches "xx^x"
>
> Could somebody explain to me why the first command isn't working as
> expected.
> I'm using grep (GNU grep) 2.5.1
>

It looks to me like you have discovered a bug. xx\^x will also work.


--
We have nowhere else to go... this is all we have.
-- Margaret Mead
  Réponse avec citation
Vieux 21/08/2006, 19h06   #3
Daniel Mentz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

On Mon, 21 Aug 2006 11:22:20 -0400, Bill Marcum wrote:
> On Mon, 21 Aug 2006 17:00:09 +0200, Daniel Mentz
> <usenet@fire-of-desire.de> wrote:
>> The following command should find all lines containing "xx^x":
>> grep "xx^x"
>> But it doesn't match lines containing "xx^x".

> It looks to me like you have discovered a bug. xx\^x will also work.

Thanks for your reply. I submitted a bug report on http://savannah.gnu.org/
I also tried it on a Solaris box and it works there.
  Réponse avec citation
Vieux 21/08/2006, 19h18   #4
Chris Mattern
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

Daniel Mentz wrote:
> I have some problems with grep and BRE (Basic Regular Expressions).
> According to my documentation, a caret which is not the first character in
> a BRE matches a literal caret.
>
> The following command should find all lines containing "xx^x":
> grep "xx^x"
>
> But it doesn't match lines containing "xx^x".
>
> Whereas
> grep ".x^x"
> works fine. It matches "xx^x"
>
> Could somebody explain to me why the first command isn't working as
> expected.
> I'm using grep (GNU grep) 2.5.1
>
> Thanks for your
> Daniel Mentz


Using GNU grep 2.5.1:

syscjm@ayato:~$ grep "xx^x" << EOF
> xxx^
> ^xxxx
> xxaxx^xb
> xx^xstuff
> now is the time
> for all xx^x
> EOF

xxaxx^xb
xx^xstuff
for all xx^x
syscjm@ayato:~$


Certainly seems to work fine to me. Perhaps you could be
more specific about your problems.


Chris Mattern
  Réponse avec citation
Vieux 21/08/2006, 19h41   #5
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

On 2006-08-21, Chris Mattern wrote:
> Daniel Mentz wrote:
>> I have some problems with grep and BRE (Basic Regular Expressions).
>> According to my documentation, a caret which is not the first character in
>> a BRE matches a literal caret.
>>
>> The following command should find all lines containing "xx^x":
>> grep "xx^x"
>>
>> But it doesn't match lines containing "xx^x".
>>
>> Whereas
>> grep ".x^x"
>> works fine. It matches "xx^x"
>>
>> Could somebody explain to me why the first command isn't working as
>> expected.
>> I'm using grep (GNU grep) 2.5.1
>>
>> Thanks for your
>> Daniel Mentz

>
> Using GNU grep 2.5.1:
>
> syscjm@ayato:~$ grep "xx^x" << EOF
> > xxx^
> > ^xxxx
> > xxaxx^xb
> > xx^xstuff
> > now is the time
> > for all xx^x
> > EOF

> xxaxx^xb
> xx^xstuff
> for all xx^x
> syscjm@ayato:~$
>
>
> Certainly seems to work fine to me. Perhaps you could be
> more specific about your problems.


I see the same problem:

$ grep --version
grep (GNU grep) 2.5.1
$ grep "xx^x" << EOF
> xxx^
> ^xxxx
> xxaxx^xb
> xx^xstuff
> now is the time
> for all xx^x
> EOF

$


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 21/08/2006, 19h51   #6
Daniel Mentz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

On Mon, 21 Aug 2006 14:18:26 -0400, Chris Mattern wrote:

> Daniel Mentz wrote:
>> The following command should find all lines containing "xx^x":
>> grep "xx^x"
>>
>> But it doesn't match lines containing "xx^x".


>> I'm using grep (GNU grep) 2.5.1

> Using GNU grep 2.5.1:
>
> syscjm@ayato:~$ grep "xx^x" << EOF
> > xxx^
> > ^xxxx
> > xxaxx^xb
> > xx^xstuff
> > now is the time
> > for all xx^x
> > EOF

> xxaxx^xb
> xx^xstuff
> for all xx^x
> syscjm@ayato:~$
>
>
> Certainly seems to work fine to me. Perhaps you could be
> more specific about your problems.


I tried the command you provided on three different machines and I get a
different output (no output at all). Would you mind trying it on another
machine as well?

I also downloaded a vanilla version of GNU grep 2.5.1 and I'm getting the
same result.

[mentz@baobab src]$ ./grep "xx^x" << EOF
> xx^x
> EOF

[mentz@baobab src]$

Thanks
Daniel Mentz
  Réponse avec citation
Vieux 21/08/2006, 20h29   #7
Chris Mattern
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

Daniel Mentz wrote:
> On Mon, 21 Aug 2006 14:18:26 -0400, Chris Mattern wrote:
>
>
>>Daniel Mentz wrote:
>>
>>>The following command should find all lines containing "xx^x":
>>>grep "xx^x"
>>>
>>>But it doesn't match lines containing "xx^x".

>
>
>>>I'm using grep (GNU grep) 2.5.1

>>
>>Using GNU grep 2.5.1:
>>
>>syscjm@ayato:~$ grep "xx^x" << EOF
>> > xxx^
>> > ^xxxx
>> > xxaxx^xb
>> > xx^xstuff
>> > now is the time
>> > for all xx^x
>> > EOF

>>xxaxx^xb
>>xx^xstuff
>>for all xx^x
>>syscjm@ayato:~$
>>
>>
>>Certainly seems to work fine to me. Perhaps you could be
>>more specific about your problems.

>
>
> I tried the command you provided on three different machines and I get a
> different output (no output at all). Would you mind trying it on another
> machine as well?
>
> I also downloaded a vanilla version of GNU grep 2.5.1 and I'm getting the
> same result.
>
> [mentz@baobab src]$ ./grep "xx^x" << EOF
>
>>xx^x
>>EOF

>
> [mentz@baobab src]$
>


My test above was done on a Debian box with a fairly up-to-date Etch
distribution, using GNU grep 2.5.1 and GNU bash 3.1.14(1)-release.
A test on a Solaris 10 box with up-to-date patches, using Solaris grep
(both /usr/bin/grep and /usr/xpg4/bin/grep) and ksh (M-11/16/88i)
produced the same successful results. At the moment, to me, it looks
to me like a bug in GNU grep that Debian patched.


Chris Mattern
  Réponse avec citation
Vieux 21/08/2006, 23h13   #8
johngnub
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret


Chris Mattern wrote:
> Daniel Mentz wrote:
> > On Mon, 21 Aug 2006 14:18:26 -0400, Chris Mattern wrote:
> >
> >
> >>Daniel Mentz wrote:
> >>
> >>>The following command should find all lines containing "xx^x":
> >>>grep "xx^x"
> >>>
> >>>But it doesn't match lines containing "xx^x".

> >
> >
> >>>I'm using grep (GNU grep) 2.5.1
> >>
> >>Using GNU grep 2.5.1:
> >>
> >>syscjm@ayato:~$ grep "xx^x" << EOF
> >> > xxx^
> >> > ^xxxx
> >> > xxaxx^xb
> >> > xx^xstuff
> >> > now is the time
> >> > for all xx^x
> >> > EOF
> >>xxaxx^xb
> >>xx^xstuff
> >>for all xx^x
> >>syscjm@ayato:~$
> >>
> >>
> >>Certainly seems to work fine to me. Perhaps you could be
> >>more specific about your problems.

> >
> >
> > I tried the command you provided on three different machines and I get a
> > different output (no output at all). Would you mind trying it on another
> > machine as well?
> >
> > I also downloaded a vanilla version of GNU grep 2.5.1 and I'm getting the
> > same result.
> >
> > [mentz@baobab src]$ ./grep "xx^x" << EOF
> >
> >>xx^x
> >>EOF

> >
> > [mentz@baobab src]$
> >

>
> My test above was done on a Debian box with a fairly up-to-date Etch
> distribution, using GNU grep 2.5.1 and GNU bash 3.1.14(1)-release.
> A test on a Solaris 10 box with up-to-date patches, using Solaris grep
> (both /usr/bin/grep and /usr/xpg4/bin/grep) and ksh (M-11/16/88i)
> produced the same successful results. At the moment, to me, it looks
> to me like a bug in GNU grep that Debian patched.
>
>
> Chris Mattern


On a Aix 4.3.3 ksh: just FYI,
$ more go
echo "A"
grep "xx^x" << EOF
xxx^
^xxxx
xxaxx^xb
xx^xsstuff
now is the time
for all xx^x
EOF

$
$ ksh go
A
xxaxx^xb
xx^xsstuff
for all xx^x

JB

  Réponse avec citation
Vieux 22/08/2006, 12h24   #9
Daniel Mentz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: grep: BRE with caret

On 21 Aug 2006 15:13:53 -0700, johngnub wrote:

> Chris Mattern wrote:
>> Daniel Mentz wrote:
>>> On Mon, 21 Aug 2006 14:18:26 -0400, Chris Mattern wrote:
>>>
>>>
>>>>Daniel Mentz wrote:
>>>>
>>>>>The following command should find all lines containing "xx^x":
>>>>>grep "xx^x"
>>>>>
>>>>>But it doesn't match lines containing "xx^x".
>>>
>>>
>>>>>I'm using grep (GNU grep) 2.5.1
>>>>
>>>>Using GNU grep 2.5.1:
>>>>
>>>>syscjm@ayato:~$ grep "xx^x" << EOF
>>>> > xxx^
>>>> > ^xxxx
>>>> > xxaxx^xb
>>>> > xx^xstuff
>>>> > now is the time
>>>> > for all xx^x
>>>> > EOF
>>>>xxaxx^xb
>>>>xx^xstuff
>>>>for all xx^x
>>>>syscjm@ayato:~$
>>>>
>>>>
>>>>Certainly seems to work fine to me. Perhaps you could be
>>>>more specific about your problems.
>>>
>>>
>>> I tried the command you provided on three different machines and I get a
>>> different output (no output at all). Would you mind trying it on another
>>> machine as well?
>>>
>>> I also downloaded a vanilla version of GNU grep 2.5.1 and I'm getting the
>>> same result.
>>>
>>> [mentz@baobab src]$ ./grep "xx^x" << EOF
>>>
>>>>xx^x
>>>>EOF
>>>
>>> [mentz@baobab src]$
>>>

>>
>> My test above was done on a Debian box with a fairly up-to-date Etch
>> distribution, using GNU grep 2.5.1 and GNU bash 3.1.14(1)-release.
>> A test on a Solaris 10 box with up-to-date patches, using Solaris grep
>> (both /usr/bin/grep and /usr/xpg4/bin/grep) and ksh (M-11/16/88i)
>> produced the same successful results. At the moment, to me, it looks
>> to me like a bug in GNU grep that Debian patched.
>>
>>
>> Chris Mattern

>
> On a Aix 4.3.3 ksh: just FYI,
> $ more go
> echo "A"
> grep "xx^x" << EOF
> xxx^
> ^xxxx
> xxaxx^xb
> xx^xsstuff
> now is the time
> for all xx^x
> EOF
>
> $
> $ ksh go
> A
> xxaxx^xb
> xx^xsstuff
> for all xx^x
>
> JB


I just compiled the CVS version of GNU grep and it works fine with it. So I
guess it's a bug which is fixed in the CVS version.
Daniel
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16406 seconds with 17 queries