Hi,
I am trying to write a script to prepare some text for use as web content.
What is happening is that all the newlines in the textfile are ignored, so I want
to be able to replace/add a few characters so that for a file containg:
Code:
This is line 1.
This is line two.
This is line four.
And this line is very long and covers more than two lines of text
so there is no need to break it up in any way.
Another short line.
is is reformatted to become:
Code:
This is line 1.<br>
This is line two.<br>
<br>
This is line four.<br>
And this line is very long and covers more than two lines of text
so there is no need to break it up in any way.<br>
Another short line.<br>
I have tried to use : tr "\n" "\n<br>" but it will only replace with same number or fewer characters.
I tried using
sed as well but was unable to find a way to search
for the newline character, I tried:
sed -e 's/\n/\n<br>/g'
sed -e 's/^M/^M<br>/g'
sed -e 's/\^M/\^M<br>/g'
but they either do not work, or end up splitting the script line apart due to being taken as newline characters in the script. Is there any way to do this?
Thanks
PS, if it helps any, I am using a BASH shell on Redhat Linux 7.0