Subject: Re: bug#26904: Wishlist: Tell grep to stop when a line matches something else.

From: Shlomi Fish <[email-masked]>
Date: Sat, 13 May 2017 09:31:05 +0300

Hi LA,

On Sat, 13 May 2017 01:10:52 -0400
[email-masked] 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 .