From owner-freebsd-questions@FreeBSD.ORG Sat Jul 13 06:52:47 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C902FFD6 for ; Sat, 13 Jul 2013 06:52:47 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms16-1.1blu.de (ms16-1.1blu.de [89.202.0.34]) by mx1.freebsd.org (Postfix) with ESMTP id 88D50137B for ; Sat, 13 Jul 2013 06:52:47 +0000 (UTC) Received: from [88.217.65.53] (helo=localhost.my.domain) by ms16-1.1blu.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Uxth7-0001tT-Dw; Sat, 13 Jul 2013 08:52:37 +0200 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.my.domain (8.14.7/8.14.3) with ESMTP id r6D6qb3l001693; Sat, 13 Jul 2013 08:52:37 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.14.7/8.14.3/Submit) id r6D6qZta001692; Sat, 13 Jul 2013 08:52:35 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Sat, 13 Jul 2013 08:52:35 +0200 From: Matthias Apitz To: Robert Bonomi Subject: Re: sed Guru wanted Message-ID: <20130713065235.GA1647@La-Habana> References: <20130712090404.GA9263@sh4-5.1blu.de> <201307121544.r6CFi7EH003683@mail.r-bonomi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201307121544.r6CFi7EH003683@mail.r-bonomi.com> X-Operating-System: FreeBSD 9.0-CURRENT r214444 (i386) User-Agent: Mutt/1.5.21 (2010-09-15) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 88.217.65.53 Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Matthias Apitz List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 06:52:47 -0000 El día Friday, July 12, 2013 a las 10:44:07AM -0500, Robert Bonomi escribió: > > I can delete in a text file with > > > > sed '/pattern1/,/pattern2/d' < file > > > > all lines between the lines with the given patterns, including themself > > also; how could I specify that the deletion should exclude the line with > > /pattern1/, i.e. the addr is something like /pattern1/+1 ? > > IF you use ed(1) style commands, then '/pattern1/+1,/pattern2/d' _is_ the > answer. > > See: 'man 1 ed', specifically the LINE ADDRSSING section. > ... I know, but I wanted it to be a 'one line command' w/o additional script files; yesterday evening, while sitting in a beergarden, I came up with the idea to first add one line to the file after the line with pattern1 and use this new pattern3 for the start of the deletion: awk -v D=pattern3 '{ print } ; /pattern1/ { print D }' | sed '/pattern3/,/pattern2/d' Thanks for your thoughts in any case matthias -- Matthias Apitz | /"\ ASCII Ribbon Campaign: www.asciiribbon.org E-mail: guru@unixarea.de | \ / - No HTML/RTF in E-mail WWW: http://www.unixarea.de/ | X - No proprietary attachments phone: +49-170-4527211 | / \ - Respect for open standards