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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18377 in the body.
You can then email your comments to 18377 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#18377; Package grep. (Mon, 01 Sep 2014 02:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to terrygalant.lists <at> fastest.cc:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Mon, 01 Sep 2014 02:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Mon, 01 Sep 2014 08:07:02 GMT) Full text and rfc822 format available.

Notification sent to terrygalant.lists <at> fastest.cc:
bug acknowledged by developer. (Mon, 01 Sep 2014 08:07:02 GMT) Full text and rfc822 format available.

Message #10 received at 18377-done <at> debbugs.gnu.org (full text, mbox):

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.




Information forwarded to bug-grep <at> gnu.org:
bug#18377; Package grep. (Mon, 01 Sep 2014 11:45:01 GMT) Full text and rfc822 format available.

Message #13 received at 18377-done <at> debbugs.gnu.org (full text, mbox):

From: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
To: terrygalant.lists <at> fastest.cc
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 20:44:35 +0900
"egrep 'libstdc++'" is taken as "egrep 'libstd(c+)+'", although I don't
see that this behaviour is clearly defined in POSIX.  Therefore, as Paul
says, it's synonymous with 'libstdc(c*)'.


On Sun, 31 Aug 2014 19:07:48 -0700
terrygalant.lists <at> fastest.cc wrote:

> 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
> 
> 





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 30 Sep 2014 11:24:04 GMT) Full text and rfc822 format available.

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.