GNU bug report logs - #18377
piping output through egrep -- escaping of "+" only needed sometimes. Why?

Previous Next

Package: grep;

Reported by: terrygalant.lists <at> fastest.cc

Date: Mon, 1 Sep 2014 02:17:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#18377: closed (piping output through egrep -- escaping of "+"
 only needed sometimes. Why?)
Date: Mon, 01 Sep 2014 08:07:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 01 Sep 2014 01:05:51 -0700
with message-id <540428DF.8070502 <at> cs.ucla.edu>
and subject line Re: bug#18377: piping output through egrep -- escaping of "+" only needed sometimes. Why?
has caused the debbugs.gnu.org bug report #18377,
regarding piping output through egrep -- escaping of "+" only needed sometimes. Why?
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
18377: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18377
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: terrygalant.lists <at> fastest.cc
To: bug-grep <at> gnu.org
Subject: piping output through egrep -- escaping of "+" only needed sometimes.
 Why?
Date: Sun, 31 Aug 2014 19:07:48 -0700
Hi all,

I'm trying to pipe of output of a command through egrep.

If I do this

	ldconfig -p | egrep "libstdc++"
		libstdc++.so.6 (libc6,x86-64) => /usr/lib64/libstdc++.so.6
		libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6

that *IS* the answer I expect.

But if I simply add a ".so" to the egrep target, it returns nothing

	ldconfig -p | egrep "libstdc++.so"
		(empty)

If I *escape* the two "+", it works again.

	ldconfig -p | egrep "libstdc\+\+.so"
		libstdc++.so.6 (libc6,x86-64) => /usr/lib64/libstdc++.so.6
		libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6

Why do I need to escape the "+" in the last case, but not in the first?

Terry


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: terrygalant.lists <at> fastest.cc, 18377-done <at> debbugs.gnu.org
Subject: Re: bug#18377: piping output through egrep -- escaping of "+" only
 needed sometimes. Why?
Date: Mon, 01 Sep 2014 01:05:51 -0700
terrygalant.lists <at> fastest.cc wrote:
> Why do I need to escape the "+" in the last case, but not in the first?

Because "+" is a special character to egrep.  The pattern "libstdc++" is 
equivalent to the pattern "libstdcc*" which matches in the first case, 
whereas the pattern "libstdc++.so" is equivalent to the pattern 
"libstdcc*.so" which does not match in the last case.


This bug report was last modified 10 years and 349 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.