sed replace newline
sed 's/\n/ /g'
sed 's/$^/ /g'
doesn't work
You have to use
sed ':a;N;$!ba;s/\n/ /g'
- create a label via :a
- append the current and next line to the pattern space via N
- if we are before the last line, branch to the created label $!ba ($! means not to do it on the last line (as there should be one final newline)).
- finally the substitution replaces every newline with a space on the pattern space (which is the whole file).
Link: