0

I have output XML file which has string in each line icn="1", this number inside the double quotes will be changing for every line. But this number is not incrementing in order, so i have to make change to update this number in order.

I have the awk command to do this, but not able to exactly replace the number between double quotes.

awk '/icn=/{sub("icn=", "icn="++v)}1' OutputFile.xml >> test.xml
  • 2
    XML is not regular, and attempting to parse, much less postprocess it, with RE tools is a path to madness. And ponies. You might instead be well served by using a DOM parser. – DopeGhoti Mar 15 at 20:10
0

It seems to me this is what you're trying to do:

awk '/icn=/ { sub(/icn=.[0-9][0-9]*/, "icn=\""++v); print } ' file.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.