by Jeremy Canfield | Updated December 8th, 2017
Let's say file.txt contains newlines after text.
Hello World How are you today?
The sed command can be used to replace the new lines with something else. In this example, new lines are replaced with a single whitespace.
~]# sed ':a;N;$!ba;s/\n/ /g' file.txt Hello World How are you today?