From owner-freebsd-questions@FreeBSD.ORG Mon Sep 24 22:10:02 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2B1216A418 for ; Mon, 24 Sep 2007 22:10:02 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 3994B13C45A for ; Mon, 24 Sep 2007 22:10:01 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (dialup245.ach.sch.gr [81.186.70.245]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id l8OM9MQU012519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 25 Sep 2007 01:09:54 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.1/8.14.1) with ESMTP id l8OM9Leu002695; Tue, 25 Sep 2007 01:09:22 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.1/8.14.1/Submit) id l8OM9IYL002694; Tue, 25 Sep 2007 01:09:18 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 25 Sep 2007 01:09:18 +0300 From: Giorgos Keramidas To: Gary Kline Message-ID: <20070924220918.GE2012@kobe.laptop> References: <20070924210751.GA46930@thought.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070924210751.GA46930@thought.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.903, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.50, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: FreeBSD Mailing List Subject: Re: sed question[s] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2007 22:10:02 -0000 On 2007-09-24 14:07, Gary Kline wrote: > Hi, > I could probably do at least part of this with an ed shell > script, but sed is probaly more standard. (I may have asked this > before, years back: FWIW. Anyhow, don't see it in my > ~/Mail/freebsd files.) > > How can I automagically delete from $1,155d AND from the > 25th line from the bottom to the last line with sed? I spent > hours last night, by-hand saving web files; now I want to get rid > of the cruft from them. > > Again, (I think) something like % sed -e 1,$155d < filefoo > [[yes?]], but then the last part stumps me. sed commands like 'd' take a pair of 'addresses'. I don't know what $1,155 means, but if you mean delete the first 155 lines, then this should be easy: sed -e '1,155d' The second part (deleting the last 25 lines) may be slightly trickier, as you don't know that you are going to hit end-of-file until you actually hit it, so some sort of bufferring is required :-/