Re: [gentoo-user] OT awk question

2018-01-18 Thread Alexander Kapshuk
On Fri, Jan 19, 2018 at 12:13 AM, Adam Carter  wrote:
> On Wed, Jan 17, 2018 at 6:16 PM, Alexander Kapshuk
>  wrote:
>>
>> On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter 
>> wrote:
>> > I'm using this to grab a section of text across multiple lines, how do i
>> > get
>> > it to exit after the first match?
>> >
>> > awk '/foo/,/bar/'
>>
>> See if this works for you:
>> awk '/foo/,/bar/{print;if(/bar/)exit}' file
>> sed '/foo/,/bar/!d;/bar/q' file
>>
> The awk line works. I didnt try the sed line. Thanks!

Good to hear.
Thanks for letting us know.

The sed line is identical in operation to the awk one:
(1). Delete anything that's not in the range of lines from /foo/ to /bar/;
(2). Print the lines that match the range specified;
(3). Quit processing further lines of input on finding the first
occurrence of /bar/;



Re: [gentoo-user] OT awk question

2018-01-18 Thread Adam Carter
On Wed, Jan 17, 2018 at 6:16 PM, Alexander Kapshuk <
alexander.kaps...@gmail.com> wrote:

> On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter 
> wrote:
> > I'm using this to grab a section of text across multiple lines, how do i
> get
> > it to exit after the first match?
> >
> > awk '/foo/,/bar/'
>
> See if this works for you:
> awk '/foo/,/bar/{print;if(/bar/)exit}' file
> sed '/foo/,/bar/!d;/bar/q' file
>
> The awk line works. I didnt try the sed line. Thanks!


Re: [gentoo-user] OT awk question

2018-01-16 Thread Alexander Kapshuk
On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter  wrote:
> I'm using this to grab a section of text across multiple lines, how do i get
> it to exit after the first match?
>
> awk '/foo/,/bar/'

See if this works for you:
awk '/foo/,/bar/{print;if(/bar/)exit}' file
sed '/foo/,/bar/!d;/bar/q' file



[gentoo-user] OT awk question

2018-01-16 Thread Adam Carter
I'm using this to grab a section of text across multiple lines, how do i
get it to exit after the first match?

awk '/foo/,/bar/'