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:
is is reformatted to become:
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
I have a file which comes every day and the file data look's as below.
Vi abc.txt
a|b|c|d\n
a|g|h|j\n
Some times we receive the file with only a new line character in the file like
vi abc.txt
\n (8 Replies)
Hi all..
I have a text file which looks like below:
abcd
efgh
ijkl
(blank space)
I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file.
I have tried options like... (14 Replies)
Hi,
I am trying to edit a script to create an XML file to upload into PuttyCM. Everything works with the exception of the NewLine character. By default this option is set to Line feed (LF). I need it to be set to NewLine (CR/LF)
<options>
<loginmacro>True</loginmacro>
... (4 Replies)
Hi Guys,
I have a file with content as below
aj.txt
"Iam
allfine" abcdef
abcd "all is
not well"
What I'm trying to say is my data has some new line characters in between quoted text. I must get ride of the newline character that comes in between the quoted text.
output must be:... (8 Replies)
I have a file (pema)with a single long record which i have to break up into multiple lines
Input
s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc
Output
s1aaaaaaaaaaaaaaaaaaaaaaa
s1bbbbbbbbbb
s1cccccccccc
m planning to do it by replacing s1 by \ns1 \n is the new line character
i... (5 Replies)
Hi All,
I have file with only one record,always be only one record. as like below.
if that line contains newline end of the line..no need to add, if not just add the new line character.
END OF FILE. ROW COUNT: 7
Please help me..
Thanks, (9 Replies)
Removed.
My question does not make sense. and SED does see the last newline character.
But I still have a question:
How to remove the last newline character(the newline character at the end of last line) using SED?
---------- Post updated 05-01-11 at 10:51 AM ---------- Previous update was... (7 Replies)
hi,
I have a for loop where in I write some file name to another file.
I want to write all the filenames to another without any newlines. how can i avoid getting new lines with echo?
Thanks,
Srilaxmi (2 Replies)
hi,
I want to print the below lines
"Message from bac logistics
The Confirmation File has not been received."
When i give like this in the code
"Message from bac logistics\n The Confirmation File has not been received."
It is giving only
Message from bac logistics\n The... (9 Replies)