Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!news.cs.indiana.edu!maytag!watmath!mks.com!tslwat!louk From: louk@tslwat.UUCP (Lou Kates) Newsgroups: comp.unix.shell Subject: Re: deleting some empty lines with sed Message-ID: <354@tslwat.UUCP> Date: 29 Apr 91 03:47:15 GMT References: <1991Apr27.143519.26256@daimi.aau.dk> Reply-To: louk@tslwat.UUCP (Lou Kates) Organization: Teleride Sage, Ltd., Waterloo Lines: 15 In article <1991Apr27.143519.26256@daimi.aau.dk> datpete@daimi.aau.dk (Peter Andersen) writes: >If two or more blank lines appear, I want to remove all but >one of these. The following awk script (its called nawk on my system) will do this: nawk 'NF || !b; {b = !NF}' b is a flag which is true if the previous input line was blank. The first statement of the script prints the current line if it has fields or if b is false (or null as it will be on the first line of input). The second statement of the script sets b. Lou Kates, Teleride Sage Ltd., louk%tslwat@watmath.waterloo.edu