BTW,
sed by default only operates on single lines at a time. It takes a line into it's pattern buffer, minus the newline, applies the given expressions to it, then re-adds the newline when printing out the results. So a simple "
s///" on its own can't ever affect multiple lines.
To do so requires telling
sed to store multiple lines into the buffer first, usually with the "
N" command. Then the substitution pattern can target the newline between them.
everToulouse showed you how it's done.
Here are a few useful sed references.
http://www.grymoire.com/Unix/Sed.html
http://sed.sourceforge.net/grabbag/
http://sed.sourceforge.net/sedfaq.html
http://sed.sourceforge.net/sed1line.txt
tr is generally the better option, though. Notice, however, that just deleting the newline characters means the lines get concatenated without any spaces between them. So this might be closer to what you expect:
Code:
tr -s '\n' ' ' <file
The
-s option "squeezes" multiple newlines into a single space, so any blank lines will be removed. Remove it if not needed.