Xref: utzoo comp.unix.shell:2094 comp.lang.perl:5171 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.unix.shell,comp.lang.perl Subject: Re: deleting some empty lines with sed Message-ID: <1991May2.191157.6715@jpl-devvax.jpl.nasa.gov> Date: 2 May 91 19:11:57 GMT References: <1991Apr27.143519.26256@daimi.aau.dk> <281DB41B.9E6@marob.uucp> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <281DB41B.9E6@marob.uucp> daveh@marob.uucp (Dave Hammond) writes: : Perhaps I'm oversimplifying the problem, but wouldn't : : tr -s '\012' : : squeeze multiple, consecutive newlines to a single newline? Yes, it would, and yes, you are. They wanted to squeeze 3 or more consecutive newlines down to 2. Incidentally, with perl 3.044 and later you can do it with perl -00pe 's/^\n+//' or, less efficiently (because of file slurping overhead and string copying due to modifying the middle of a long string, and because the previous solution uses anchored search), perl -0777pe 's/\n{3,}/\n\n/g' Oddly enough, any octal number will work in place of 0777 except 012, which would set the input delimiter to newline. Larry Wall lwall@netlabs.com