I want to edit the config file of a program that is an XML:
<software>
<settings>
...
<setting name="local directory" type="string">/home/username/</setting>
...
</settings>
</software>
What is the easiest way to do this from a bash script?
Thanks
Using xmlstarlet:
xmlstarlet val -e file.xml
xmlstarlet ed -u "//settings/setting/@name" -v 'local directory2' file.xml
xmlstarlet ed -u "//settings[1]/setting/@name" -v 'local directory2' file.xml
# edit file inplace
xmlstarlet ed -L -u "//settings/setting/@name" -v 'local directory2' file.xml