Date: Tue, 25 Sep 2007 01:09:18 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Gary Kline <kline@tao.thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: sed question[s] Message-ID: <20070924220918.GE2012@kobe.laptop> In-Reply-To: <20070924210751.GA46930@thought.org> References: <20070924210751.GA46930@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2007-09-24 14:07, Gary Kline <kline@tao.thought.org> 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 :-/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070924220918.GE2012>