Update selected tag values in XML file using shell script -
i have xml file similar below format:
<name>property1</name> <fullname>property1</fullname> <info> #property info# </info> <value> <current>true</current> <default>false</default> </value> <name>property2</name> <fullname>property2</fullname> <info> #property info# </info> <value> <current>true</current> <default>false</default> </value> <name>property3</name> <fullname>property3</fullname> <info> #property info# </info> <value> <current>true</current> <default>false</default> </value>
the xml file contains hundreds of such properties. want update value of current tag of few properties (say property2) true false. how can using unix commands?
i'm new unix , i'm looking write unix shell script this. appreciated.
thanks!
i think, useful you:
http://www.unixcl.com/2010/01/replace-values-in-xml-using-sed-and-awk.html
later edit:
this it:
cat asd.xml | awk '{ x[nr] = $0 } end { ( i=1 ; i<=nr ; i++ ) { if (x[i] ~ /<name>property2/ ) {x[i+4]=" <current>false</current>"}print x[i] }} ' > newfile.xml
where asd.xml original file, , newfile.xml new one. sure original file first!
Comments
Post a Comment