This is rude because sed usually processes the string at a time:
sed -e :a -e N -e 's/\n/ /' -e ta input.txt
It is better:
tr '\n' ' ' < input.txt
I decided to replace the new line with a space. tr can replace only one character (or delete with the -d option).
Flexibility and simplicity:
perl -ne 'chomp;print $_," "' input.txt
Where "" is what you want instead of a new line.
source
share