From af137@torfree.net Mon Jun 22 17:32:00 1998 Newsgroups: comp.os.msdos.programmer,comp.editors,comp.unix.questions,comp.unix.misc,alt.comp.editors.batch Path: fu-berlin.de!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!news1.bellglobal.com!torfree!af137 From: af137@torfree.net (Al Aab) Subject: . extract lines Message-ID: Organization: Toronto Free-Net X-Newsreader: TIN [version 1.2 PL2] Date: Tue, 9 Jun 1998 20:29:25 GMT Lines: 43 Xref: fu-berlin.de comp.os.msdos.programmer:104106 comp.editors:31634 comp.unix.questions:117554 comp.unix.misc:39976 alt.comp.editors.batch:2643 seders sed mail list has a couple of sed studs. 1such is Greg Ubben. i scan newsgroups for sedable problems, sedcast them to seders mail list, get seders solutions. here is a gem : Subject: Re: off newsgroups: extracting lines > >I'm writing a Bourne shell script, in which I need to extract some lines > >from the middle of a file. I have a file with a known number of lines on > >top (41) and bottom (16), but an unknown number of lines in the middle. > >I want to remove these lines on the top and bottom and keep the lines in > >the middle. > > > >Kevin Outman This should work: sed -e "1,41d;:a" -e "N;43,57ba" -e "P;D" Uses a 16-line look-ahead in order to stop 16 lines from the bottom. Original author's email address wasn't included so couldn't cc him... Greg --------- to master regular expressions to master sed join my seders informal email list -- =-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- al aab, seders moderator sed u soon it is not zat we do not see the s o l u t i o n -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+