Hi, Thanks to RudiC I have a functioning awk portion of a script which reads a text file and replaces all matching values in an XML.
I need help with placing print statements in the script to see line by line what is being replaced.
Script:
#!/bin/sh
if [ $# -eq 2 ]
then
echo
else
echo "usage: $0 <Properties> <DeploymentXML>"
exit
fi
TXT=$1
XML=$2
awk '
FNR == NR {sub (/\./, "/", $TXT)
T[$TXT] = $XML
next
}
{for (t in T) if ($0 ~ t) TF = t
}
TF && /<value/ {sub (/>[^<]*</, ">" T[TF] "<")
TF = ""
}
TF && /<machine/{sub (/>[^<]*</, ">" T[TF] "<")
TF = ""
}
1
' FS="~" $TXT $XML > temp && mv temp $XML
For example:
Text file contains multiple entries in the format of -
Application.Env~DEV
Application.ID~99999
Pre-script XML contains multiple entries in the format of -
<name>Application/Env</name>
<value>XXX</value>
<name>Application/ID</name>
<value>00000</value>
Post-script XML:
<name>Application/Env</name>
<value>DEV</value>
<name>Application/ID</name>
<value>99999</value>
Thanks!