From owner-freebsd-questions@FreeBSD.ORG Sat Jan 17 21:17:23 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 2CCDC16A4CE for ; Sat, 17 Jan 2004 21:17:23 -0800 (PST) Received: from sage.thought.org (dsl231-043-140.sea1.dsl.speakeasy.net [216.231.43.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B44B43D39 for ; Sat, 17 Jan 2004 21:17:20 -0800 (PST) (envelope-from kline@thought.org) Received: from thought.org (root@tao [10.0.0.247]) by sage.thought.org (8.12.9/8.11.4) with ESMTP id i0I5H0GH048940; Sat, 17 Jan 2004 21:17:03 -0800 (PST) (envelope-from kline@thought.org) Received: (from kline@localhost) by thought.org (8.12.6/8.11.3) id i0I5Gw50068692; Sat, 17 Jan 2004 21:16:58 -0800 (PST) (envelope-from kline) Date: Sat, 17 Jan 2004 21:16:57 -0800 From: Gary Kline To: Rob Message-ID: <20040118051657.GC68597@tao.thought.org> References: <20040118030911.GA18161@tao.thought.org> <20040117215110.R602@grond.sourballs.org> <007d01c3dd7d$d0917530$a4b826cb@goo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <007d01c3dd7d$d0917530$a4b826cb@goo> X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: Observing 17 years of service to the Unix community User-Agent: Mutt/1.5.5.1i cc: Gary Kline cc: David Fleck 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 05:17:23 -0000 On Sun, Jan 18, 2004 at 03:14:50PM +1030, Rob wrote: > 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 }' > > ? Seems like this takes fewer keystrokes... I don't know much awsk, but is there a way of feeding awk a cmd if the cont returns true? Say: cmd1 | awk '{print $9}' == 'foo.c' then echo "Found foo.c" mv foo.c ~/C_file END it's mostly like a perl hack, tho. anyway, thanks, gents, gary -- Gary Kline kline@thought.org www.thought.org Public service Unix