I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the file
Tried the below code
readsrror=`cat newfile.txt`
echo "<html>" >>email.html
echo "<body>" >>email.html
for i in $(echo $readsrror| sed "s/endresult/ /g")
do
echo "<tr>" >>email.html
echo "$i" >>email.html# only the tag is getting copied not the entire content.
echo "</tr>" >>email.html
done
echo "</body>" >>email.html
echo "</html>" >>email.html
Thanks nezabudka , but these commands copy the entire content to my file in <tr> row,but I need to split the content from my base file and iterate through and copy each content into a <tr> tag.
Eg: Something like the below
read file
Split based on value <end>
for i to splitcount
<tr> $i</tr>
done
output:
<tr> errormessga [object not found :line 30 ]</tr>
<tr> Null pointer exceptions [no value available for the input :name ]</tr>
It would seem that you would be much more likely to get what you want if you process the contents of your XML file directly instead of reading it into a variable and then echo ing those contents into sed .
You are asking us to make lots of guesses about what you are doing since you haven't shown us the input file that you are hoping will be translated to the output you say you want in post #5 in this thread. And the pseudo-code in post #5 doesn't really help because it contains a syntax error (i.e., there is no for i to splitcount command in any shell command language I've seen. Please show us the contents of the file (in CODE tags) you want to process to produce the output shown in post #5.
What shell are you using?
What operating system are you using? (Note that the standards say that the results are unspecified if the input file you feed into sed is not a text file. Using echo to convert the contents of a file into a single line may exceed the line length allowed in a text file depending on what operating system and what version of sed on that operating system you're using.)