I am running this script:
INPUTNAME=ABC.XYZ
FILENAME="Sample.xml"
awk -v inputName=$INPUTNAME '
/<machine.*name=/ { f=1 ; m=0 ; res="" }
f { res = res $0 ORS }
f && /<details input="inputName"/ { m=1 }
/<\/machine>/ { f=0 ; if (m) print res $0 }
' $FILENAME
to get an output like this
<machine name="sample1" min="1" max="10" idleTime="300" backend="ABC,XYZ">
<handler className="com.abc.xyz.qwerty.foo.FooBar" />
<details input="ABC.XYZ" suggExpiry="30" minExpiry="4" maxExpiry="500"/>
</machine>
but the parameter input is failing. What seems to be wrong in the script?
NOTE:
I ran it with hardcoded values (not using parameters) and it run smoothly