public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
To: Gentoo mailing list <gentoo-user@lists.gentoo.org>
Subject: Re: [gentoo-user] OT awk question
Date: Fri, 19 Jan 2018 06:20:33 +0200	[thread overview]
Message-ID: <CAJ1xhMUB+mDCy-tseB6psKSG8yEapwieD4sfSWd-_0MqsHoLMg@mail.gmail.com> (raw)
In-Reply-To: <CAC=wYCGPy0PgJOXxYqewoExM4cLjxy7UNODtOKwt=qtVQazHEw@mail.gmail.com>

On Fri, Jan 19, 2018 at 12:13 AM, Adam Carter <adamcarter3@gmail.com> wrote:
> On Wed, Jan 17, 2018 at 6:16 PM, Alexander Kapshuk
> <alexander.kapshuk@gmail.com> wrote:
>>
>> On Wed, Jan 17, 2018 at 3:49 AM, Adam Carter <adamcarter3@gmail.com>
>> 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/;


      reply	other threads:[~2018-01-19  4:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17  1:49 [gentoo-user] OT awk question Adam Carter
2018-01-17  3:19 ` [gentoo-user] " Ian Zimmerman
2018-01-17  7:16 ` [gentoo-user] " Alexander Kapshuk
2018-01-18 22:13   ` Adam Carter
2018-01-19  4:20     ` Alexander Kapshuk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ1xhMUB+mDCy-tseB6psKSG8yEapwieD4sfSWd-_0MqsHoLMg@mail.gmail.com \
    --to=alexander.kapshuk@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox