It looks like that it should be easy with sed because we have used substitute and the replacing character so it should be
sed 's/\n/\t/g' filename or
sed 's/\n/ /g' filename or
sed 's/\n//g' filename
but when you will try these solutions, none of these will work because to change line you have to define all these
Code:
:a create a label 'a'
N append the next line to the pattern space
$! if not the last line, ba branch (go to) label 'a'
s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
But it does not like that if it is not done in sed, it can't be done. There are other several and much easy ways.
You have to replace new line with another character, in these examples I am replacing it with space.
If you do this using perl in a way like sed,
Code:
perl -p -e 's/\n/ /' filename.txt
with tr
Code:
tr '\n' ' ' < filename.txt
Another way with paste,
but here is some limitation, if you replace new line with one or two character(like space or tab), it is easy to use, if there are multiple charcters there can be some problem.
Code:
paste -s -d ' ' filename.txt