Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!rutgers!njin!uupsi!sunic!dkuug!daimi!datpete From: datpete@daimi.aau.dk (Peter Andersen) Newsgroups: comp.unix.shell Subject: deleting some empty lines with sed Message-ID: <1991Apr27.143519.26256@daimi.aau.dk> Date: 27 Apr 91 14:35:19 GMT Sender: datpete@daimi.aau.dk (Peter Andersen) Reply-To: datpete@daimi.aau.dk (Peter Andersen) Organization: DAIMI: Computer Science Department, Aarhus University, Denmark Lines: 20 I have some source-files that I produce documentation from. I use sed to make a few changes to the text. I have figured most of it out, but I have one problem remaining: If two or more blank lines appear, I want to remove all but one of these. I have tried the following sed script s^ *$//p 1,$ N s/\(\n\n\)\n*/\1/gp but it didn't work. Does anyone have a way of doing this, perhaps using something else but sed. I'm not a perl-guru, but if its possible in perl I'd like to hear about that too. Peter