I have an XML file that has a set of entries like this:
<attr name="trajectory" value="nodo2"/>
What I want to do is to substitute the value field in each entry of the file by an entry of the form "nodoX", where X should be read from a second file that contains a list of numbers, e.g "file2" contains:
4
8
67
52
In that case my processed XML file should have substituted the previous entries by:
<attr name="trajectory" value="nodo4"/>
...
<attr name="trajectory" value="nodo8"/>
...
<attr name="trajectory" value="nodo67"/>
...
<attr name="trajectory" value="nodo52"/>
...
Currently I am trying with the following awk command but it is not working:
awk '/"trajectory"/ {if (getline < "file2") {x=$1; sub(/"nodo2"/,"\"nodo"x"\"")}}1' $XML_INPUT_FILE > $XML_OUTPUT_FILE
Could someone advise the correct way to get this done in awk ?
Thanks
Daniel