From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1LdxYz-0001nl-LE for garchives@archives.gentoo.org; Mon, 02 Mar 2009 02:07:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 19D85E02DA; Mon, 2 Mar 2009 02:07:24 +0000 (UTC) Received: from mail.fraggod.net (unknown [91.191.238.58]) by pigeon.gentoo.org (Postfix) with ESMTP id D34F8E02DA for ; Mon, 2 Mar 2009 02:07:23 +0000 (UTC) Received: from coercion (coercion.core [IPv6:2001:470:1f0b:11de::13]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.fraggod.net (Postfix) with ESMTPSA id D3870101FDB for ; Mon, 2 Mar 2009 07:07:22 +0500 (YEKT) Date: Mon, 2 Mar 2009 07:04:09 +0500 From: Mike Kazantsev To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Grep question Message-ID: <20090302070409.2dad3992@coercion> In-Reply-To: <5602B0BD6D59AE4791BE83104940118D7B1B328A@excprdmbxw002.optus.com.au> References: <5602B0BD6D59AE4791BE83104940118D7B1B328A@excprdmbxw002.optus.com.au> X-Mailer: Claws Mail 3.7.0 (GTK+ 2.14.7; i686-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/1gqjCJw0+WsLs8N5l4JPE5X"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Archives-Salt: a6d82919-51f6-4fa8-b983-24caa9be248e X-Archives-Hash: 64e2b8a2ad46fbb3c5a6d228e2cae1ca --Sig_/1gqjCJw0+WsLs8N5l4JPE5X Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 2 Mar 2009 13:01:31 +1100 Adam Carter wrote: > I need to select all the lines between string1 and string2 in a file. Str= ing1 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 --=20 Mike Kazantsev // fraggod.net --Sig_/1gqjCJw0+WsLs8N5l4JPE5X Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (GNU/Linux) iEYEARECAAYFAkmrPp0ACgkQASbOZpzyXnGgsgCgvBXFkmAHo3xkJrNAbG4YAO8N bhIAn0eKkX60beMjCVe6RkGzwae79i5H =mklB -----END PGP SIGNATURE----- --Sig_/1gqjCJw0+WsLs8N5l4JPE5X--