GNU bug report logs - #26904
Wishlist: Tell grep to stop when a line matches something else.

Previous Next

Package: grep;

Reported by: LA-notifications <at> xecu.net

Date: Sat, 13 May 2017 05:57:01 UTC

Severity: wishlist

To reply to this bug, email your comments to 26904 AT debbugs.gnu.org.

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#26904; Package grep. (Sat, 13 May 2017 05:57:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to LA-notifications <at> xecu.net:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Sat, 13 May 2017 05:57:01 GMT) Full text and rfc822 format available.

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

From: LA-notifications <at> xecu.net
To: bug-grep <at> gnu.org
Subject: Wishlist: Tell grep to stop when a line matches something else.
Date: Sat, 13 May 2017 01:10:52 -0400
Hello.

I wish I could tell grep to stop searching in a file when it gets to a 
line matching something else. So if grep is searching a file for 'foo' 
then finds a line matching 'bar', stop searching for 'foo'. It would 
help me out a lot when searching for things in my perl modules where I 
do not want my perl pod searched.

LA




Information forwarded to bug-grep <at> gnu.org:
bug#26904; Package grep. (Sat, 13 May 2017 06:37:02 GMT) Full text and rfc822 format available.

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

From: Shlomi Fish <shlomif <at> shlomifish.org>
To: LA-notifications <at> xecu.net
Cc: 26904 <at> debbugs.gnu.org
Subject: Re: bug#26904: Wishlist: Tell grep to stop when a line matches
 something else.
Date: Sat, 13 May 2017 09:31:05 +0300
Hi LA,

On Sat, 13 May 2017 01:10:52 -0400
LA-notifications <at> xecu.net wrote:

> Hello.
> 
> I wish I could tell grep to stop searching in a file when it gets to a 
> line matching something else. So if grep is searching a file for 'foo' 
> then finds a line matching 'bar', stop searching for 'foo'. It would 
> help me out a lot when searching for things in my perl modules where I 
> do not want my perl pod searched.
> 

It may be out of the scope of GNU grep, but should be doable in perl -ln or sed.
E.g (untested):

perl -ln -E '/bar/?exit:/foo/?say:0'

Regards,

	Shlomi Fish

> LA
> 
> 
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/facts/Emma-Watson/

A wiseman can learn from a fool much more than a fool can ever learn from a
wiseman.               — http://en.wikiquote.org/wiki/Cato_the_Elder

Please reply to list if it's a mailing list post - http://shlom.in/reply .




This bug report was last modified 7 years and 184 days ago.

Previous Next


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