From owner-freebsd-questions@FreeBSD.ORG Sat Jan 17 20:58:54 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 6C49116A4CE for ; Sat, 17 Jan 2004 20:58:54 -0800 (PST) Received: from gabby.gsicomp.on.ca (00062566C7BB.cpe.net.cable.rogers.com [24.192.222.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB07043D1D for ; Sat, 17 Jan 2004 20:58:52 -0800 (PST) (envelope-from matt@gsicomp.on.ca) Received: from hermes (hermes.gsicomp.on.ca [192.168.0.18]) by gabby.gsicomp.on.ca (8.12.9p2/8.12.9) with SMTP id i0I3ePW5080075; Sat, 17 Jan 2004 22:40:26 -0500 (EST) (envelope-from matt@gsicomp.on.ca) Message-ID: <002601c3dd74$55f46250$1200a8c0@gsicomp.on.ca> From: "Matt Emmerton" To: "Gary Kline" , "FreeBSD Mailing List" References: <20040118030911.GA18161@tao.thought.org> Date: Sat, 17 Jan 2004 22:37:00 -0500 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 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:58:54 -0000 > 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? > > tia, everybody, > > gary If I'm understanding your question correctly, this Perl script should do it. #!/bin/perl while (<>) { if (/^PATTERN) { last; } print $_; } -- Matt Emmerton