Gentoo Archives: gentoo-user

From: Alexander Kapshuk <alexander.kapshuk@×××××.com>
To: Gentoo mailing list <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] OT awk question
Date: Wed, 17 Jan 2018 07:17:43
Message-Id: CAJ1xhMUWMYzGFwBvNeZcuJBM+qo9Qeb84z-dvBP5v9xS+GA_6Q@mail.gmail.com
In Reply to: [gentoo-user] OT awk question by Adam Carter
1 On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter <adamcarter3@×××××.com> wrote:
2 > I'm using this to grab a section of text across multiple lines, how do i get
3 > it to exit after the first match?
4 >
5 > awk '/foo/,/bar/'
6
7 See if this works for you:
8 awk '/foo/,/bar/{print;if(/bar/)exit}' file
9 sed '/foo/,/bar/!d;/bar/q' file

Replies

Subject Author
Re: [gentoo-user] OT awk question Adam Carter <adamcarter3@×××××.com>