Solved sed script not working



Reaction score: 101
Messages: 2,438

I was looking for a sed script to concatenate mutiple lines into one and came across this post which provided this script
sed -e :a -e N -e 's/\n/ /' -e ta yourfile.txt >newfile.txt
with the following explanation
:a # label 'a' to jump back to later on
N # Append next line to sed's buffer
s/\n/ / # replace exactly one newline (\n) with a space
ta # if the last replace command was succesfull, jump to label 'a'.
# (if this does not happen, the entire file was read: end
I tried this, but it doesn't work. Is it only for GNU sed?



Reaction score: 20
Messages: 55

On GNU sed it works right as it is, or as this:

sed -e ':a N; s/\n/ /; ta' yourfile.txt >newfile.txt

Unfortunatelly it doesn't works on our sed :(

Can't you replace those newlines using something like this?
cat yourfile.txt | tr '\n' ' ' >newfile.txt