Gentoo Archives: gentoo-user

From: Adam Carter <adamcarter3@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT awk question
Date: Thu, 18 Jan 2018 22:13:21
Message-Id: CAC=wYCGPy0PgJOXxYqewoExM4cLjxy7UNODtOKwt=qtVQazHEw@mail.gmail.com
In Reply to: Re: [gentoo-user] OT awk question by Alexander Kapshuk
1 On Wed, Jan 17, 2018 at 6:16 PM, Alexander Kapshuk <
2 alexander.kapshuk@×××××.com> wrote:
3
4 > On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter <adamcarter3@×××××.com>
5 > wrote:
6 > > I'm using this to grab a section of text across multiple lines, how do i
7 > get
8 > > it to exit after the first match?
9 > >
10 > > awk '/foo/,/bar/'
11 >
12 > See if this works for you:
13 > awk '/foo/,/bar/{print;if(/bar/)exit}' file
14 > sed '/foo/,/bar/!d;/bar/q' file
15 >
16 > The awk line works. I didnt try the sed line. Thanks!

Replies

Subject Author
Re: [gentoo-user] OT awk question Alexander Kapshuk <alexander.kapshuk@×××××.com>