Hello,
I'm looking again for your precious help.
I'm running an IBM AIX box.
I have 'wrong' xml files and waiting for the bug correction I need to manipulate them
The problem is a missing tag.
Now you know that xmls are full of < and > and \ so our scripts just go beserk.
To be on the safe side I want to insert a tag between two known tags:
wrong data
<PackDate>20160615</PackDate>
<TMCCode>BA</TMCCode>
<FullPallet>N</FullPallet>
<BlockCode>0</BlockCode>
<AdmQualifier>568U#3-335</AdmQualifier>
correct data
<PackDate>20160615</PackDate>
<TMCCode>BA</TMCCode>
<FullPallet>N</FullPallet>
<AviExp>123456</AviExp>
<BlockCode>0</BlockCode>
<AdmQualifier>568U#3-335</AdmQualifier>
Instead of using while...read... I tried gsub, but all those fancy delimiters just don't let the command to work properly. Furthermore there are CRLF that are to be taken into account.
This is my try:
awk '{gsub("<FullPallet>N</FullPallet>\n<BlockCode>0</BlockCode>","<FullPallet>N</FullPallet>\n<AviExp>123456</AviExp>\n<BlockCode>0</BlockCode>");printf"%s",$0}' S210404890.xml > test.txt
Any help is really appreciated.
thanks,
Ema