From owner-freebsd-questions@FreeBSD.ORG Sat Jan 17 19:54:30 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 141FC16A4CE for ; Sat, 17 Jan 2004 19:54:30 -0800 (PST) Received: from sccmmhc02.asp.att.net (sccmmhc02.asp.att.net [204.127.203.184]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A48143D39 for ; Sat, 17 Jan 2004 19:54:29 -0800 (PST) (envelope-from david.fleck@mchsi.com) Received: from grond (12-216-14-105.client.mchsi.com[12.216.14.105]) by sccmmhc02.asp.att.net (sccmmhc02) with SMTP id <20040118035428mm2009q17pe>; Sun, 18 Jan 2004 03:54:28 +0000 Date: Sat, 17 Jan 2004 21:54:27 -0600 (CST) From: David Fleck Sender: dcf@grond.sourballs.org To: Gary Kline In-Reply-To: <20040118030911.GA18161@tao.thought.org> Message-ID: <20040117215110.R602@grond.sourballs.org> References: <20040118030911.GA18161@tao.thought.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 03:54:30 -0000 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 -- David Fleck david.fleck@mchsi.com