I am using this XML file: https://github.com/apache/ranger/blob/master/ugsync/src/test/resources/ranger-ugsync-site.xml
Now, I have to update the value of the following property to false.
<property>
<name>ranger.usersync.group.usermapsyncenabled</name>
<value>true</value>
</property>
To update the value of property in the XML to false, I am using the below command in the bash script to get the updates done.
tag1=<name>ranger.usersync.group.usermapsyncenabled</name>
file=xml_file.xml
temporary=temp.xml
grep -A1 $tag1 $file | grep -v $tag1 | sed -e "s/^.*<value>/<value/" | sed -e "s/<value>true<\/value>/<value>false<\/value>/g" $file > $temporary
Problem: The script is updating all the other attributes in the file with value true to false. I just need to update the value of this attribute and not others. Input/help is appreciated. Thanks!
grepandsedto ignore XML comments and CDATA sections, and to readxmlnstags to figure out the current namespace, and to read DTDs and understand any macros they contain, etc.