I have an xml file
<?xml version="1.0"?>
<preferences>
<!--General options-->
<options>
<dbHost>localhost</dbHost>
<dbUser>bwserver</dbUser>
<dbPass>bwserver</dbPass>
<dbPort>3306</dbPort>
How can i update the value dbUser?
When I type
xmlstarlet edit --update '/preferences/options/dbUser/' --value 123 preferences.xml
nothing happens. I only see the file contents in terminal. The xml file was not touched.
You have two faults:
/preferences/options/dbUser
xmlstarlet edit --update '/preferences/options/dbUser' --value 123 preferences.xml > preferences.xml
or you can use global option --inplace
which replaces the input file with the output (instead of printing it to stdin). The command is xmlstarlet edit --inplace --update '/preferences/options/dbUser' --value 123 preferences.xml
Type xmlstarlet edit --help
for more info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With