in reply to Re: newlines in regular expressions
in thread newlines in regular expressions

A few nits: The first answer requires that Perl read in slurp mode, and needs a g modifier to replace all occurences:
perl -p -e 'BEGIN { undef $/ } s/\n{2,}/\n/g'

Also, the two examples behave differently in the face of lines that contain only blank characters, like space and tab. The second will delete them, while the first will leave them intact. You can make the second leave them intact by using m/^$/; to make the first delete whitespace-only lines I think s/\n\s*\n/\n/g will work, but I haven't thought it through yet.