From owner-freebsd-questions@FreeBSD.ORG Sat Jan 17 20:45:11 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7717F16A4CE for ; Sat, 17 Jan 2004 20:45:11 -0800 (PST) Received: from zim.0x7e.net (zim.0x7e.net [203.38.184.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CD5D43D1D for ; Sat, 17 Jan 2004 20:45:10 -0800 (PST) (envelope-from listone@deathbeforedecaf.net) Received: from goo.0x7e.net ([203.38.184.164] helo=goo) by zim.0x7e.net with smtp (Exim 3.36 #1) id 1Ai4nu-0003By-00; Sun, 18 Jan 2004 15:14:54 +1030 Message-ID: <007d01c3dd7d$d0917530$a4b826cb@goo> From: "Rob" To: "David Fleck" , "Gary Kline" References: <20040118030911.GA18161@tao.thought.org> <20040117215110.R602@grond.sourballs.org> Date: Sun, 18 Jan 2004 15:14:50 +1030 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 cc: FreeBSD Mailing List Subject: Re: stumped... . X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jan 2004 04:45:11 -0000 David Fleck wrote on Sunday January 18, 2004: > On Sat, 17 Jan 2004, Gary Kline wrote: > > > > > I've written scores of scripts to hack text files, but this > > one has me dead in the water. > > > > How can I delete all lines from /^PATTERN to EOF?? > > > > ed - < > > > /^PATTERN > > (.,$)d > > w > > q > > foo > > > > or anything else I've tried doesn't do it. I could do it in > > C/C++,but c'mon... ! Any solutions in sed, perl, or ed/ex? > > Well, you didn't mention awk, but... > > > awk '$0 ~ /^PATTERN/ {x=1}; {if (x!=1) print $0}' < foo > bar > Wouldn't it be neater to do nawk '/^PATTERN/ { exit } ; { print }' ?