Possible Duplicate:
SED: How can I replace a newline (\n)?
I have the file with newlines. and I am trying this
sed -re 's/\n//' sample1.txt
and it's not working
It's showing output with newlines and not removing them.
Possible Duplicate:
SED: How can I replace a newline (\n)?
I have the file with newlines. and I am trying this
sed -re 's/\n//' sample1.txt
and it's not working
It's showing output with newlines and not removing them.
sed
splits the input it receives at newlines and removes them before running the sed script, i.e. the script will never see then newlines. Use tr instead:
tr -d '\n'
Or if you insist on sed
, use Guru's looped solution which re-inserts \n
with the N
command.
Use double quotes:
sed -e "s/\n//" sample1.txt
If your intention is to try and join all lines in a file:
sed -e :a -e 'N;s/\n//;ta' sample1.txt