in reply to Making my file all one line


Here is a one-liner. It preserves a final "\n" if one or more exists.
perl -00 -pe 's/ $/\012/ if s/\n+/ /g and eof' file
Here are some variations:
perl -00 -pe '(eof) ? s/\n\n/\n/ : s/\n+/ /g ' file perl -00 -pe 's/\n+/(eof) ? "\n" : " "/eg ' file
Choose eof or eof() to get the desired effect when dealing with multiple files.

--
John.