Hi folks
I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file.
It all works - apart from the xml and config file format in the new file
with XML files the original XML (that ends up in the destination file)
<no action="setACL" send="Y">
<ACL node="" name="" value="" />
<ACL node="" name="" value="01" />
</no>
but it should look like this (this is the new stuff I am inserting)
<bit bitpos="" action="setACL" no="Y">
<ACL node="" name="" value="Default" />
<ACL node="" name="" value="00" />
</bit>
on config files - which are just standard flat files,the original file looks like this:
# -------------------------------------------------
# LB Health Check
# -------------------------------------------------
User-Name Equals LB accountwrite=n
but I get this:
# -------------------------------------------------
# LB Health Check
# -------------------------------------------------
User-Name Equals LB accountwrite=n
I use the same function for each file - the content is spot on I just cannot see how to get the xml formatting correct (the non-xml files I can live with) and looks like this :
tFile=/tmp/newtest.tmp
if [ -e ${dFile} ]; then rm -rf ${dFile}; fi
while read line
do
let cnt=cnt+1;
if [ ${cnt} -eq ${insertAtLine} ]; then
echo -e "${insertThis}" >> ${dFile}
echo -e "**** Inserted OK! ****"
else
echo -e ${line} >> ${dFile}
fi
done < ${sFile}
cnt=0
$insertThis is the text I need to insert
$insertAtLine is the line I need to insert the text at
$dFile = destination file
$tFile = temporary file
so, basically
echo -e "${insertThis}" >> ${dFile}
works, and
echo -e ${line} >> ${dFile}
this is whats giving me grief!
This is driving me crazy btw,