From: Mike Kazantsev <mike_kazantsev@fraggod.net>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Grep question
Date: Mon, 2 Mar 2009 07:04:09 +0500 [thread overview]
Message-ID: <20090302070409.2dad3992@coercion> (raw)
In-Reply-To: <5602B0BD6D59AE4791BE83104940118D7B1B328A@excprdmbxw002.optus.com.au>
[-- Attachment #1: Type: text/plain, Size: 619 bytes --]
On Mon, 2 Mar 2009 13:01:31 +1100
Adam Carter <Adam.Carter@optus.com.au> wrote:
> I need to select all the lines between string1 and string2 in a file. String1 exists on an entire line by itself and string2 will be at the start of a line. What's the syntax? I cant use -A as there is a variable number of lines.
I doubt there's a solution involving grep, unless you use it twice in
the same pipe:
grep -A9999 string1 /some/file | grep -B 9999 string2
But there can be any amount of more elegant solutions, involving
sed:
sed -n '/string1/,/string2/p' /some/file
--
Mike Kazantsev // fraggod.net
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2009-03-02 2:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-02 2:01 [gentoo-user] Grep question Adam Carter
2009-03-02 2:04 ` Mike Kazantsev [this message]
2009-03-02 10:01 ` Steven Lembark
2009-03-02 14:06 ` [gentoo-user] " James
2009-03-03 2:10 ` Harry Putnam
2009-03-03 9:52 ` Etaoin Shrdlu
2009-03-05 16:54 ` Harry Putnam
2009-03-05 23:01 ` Adam Carter
2009-03-06 9:33 ` Etaoin Shrdlu
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=20090302070409.2dad3992@coercion \
--to=mike_kazantsev@fraggod.net \
--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