One-liner to convert two newlines to one?

Posted by Joseph Turian on Stack Overflow See other posts from Stack Overflow or by Joseph Turian
Published on 2009-09-24T00:04:37Z Indexed on 2010/05/04 0:48 UTC
Read the original article Hit count: 287

Filed under:
|
|

I have a file where I want to convert "\n" to " " and "\n\n" to "\n". For example:

I
had
a
toy
.

It
was
good
.

Becomes:

I had a toy .
It was good .

Does anyone have a Unix one-liner for this operation?

© Stack Overflow or respective owner

Related posts about unix

Related posts about one-liner