Hi
I have an xml-file containing multiple records like:
<DPparameter>
<SWid>SCMTYPE</SWid>
<position>500</position>
<size>16</size>
</DPparameter>
All records currently indicate position 500.
What I want to do is replace 500 with 500 + a running number.
I've tried running the code below with nawk:
BEGIN{
count = 0
}
{
newposition = firstposition + count
if(gsub(/500/, newposition)) {
print "Replaced 500 with " newposition
count++
}
}
The variable firstposition is given as input on the command line which looks like:
> nawk -f Replace firstposition=500 XmlTestFile
The output I get looks like the operation has succeded:
Replaced 500 with 500
Replaced 500 with 501
Replaced 500 with 502
Replaced 500 with 503
...etc...
However, nothing has changed in my file.
What am I doing wrong. I just can't find out.
I'm going crazy!
Thanks a lot in advance for your help.
I have an xml-file containing multiple records like:
<DPparameter>
<SWid>SCMTYPE</SWid>
<position>500</position>
<size>16</size>
</DPparameter>
All records currently indicate position 500.
What I want to do is replace 500 with 500 + a running number.
I've tried running the code below with nawk:
BEGIN{
count = 0
}
{
newposition = firstposition + count
if(gsub(/500/, newposition)) {
print "Replaced 500 with " newposition
count++
}
}
The variable firstposition is given as input on the command line which looks like:
> nawk -f Replace firstposition=500 XmlTestFile
The output I get looks like the operation has succeded:
Replaced 500 with 500
Replaced 500 with 501
Replaced 500 with 502
Replaced 500 with 503
...etc...
However, nothing has changed in my file.
What am I doing wrong. I just can't find out.
I'm going crazy!
Thanks a lot in advance for your help.