I have to extract a parameter from a configuration file, and replace its values with another given value.
The config file is:
<host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/>
I have to replace the value of xmldefaulttimeout="2.0" with another value, for example: xmldefaulttimeout="4.0".
As in the text, xmldefaulttimeout=”2.0″, but in fact, the value “2.0” is not certain. It may be another uncertain value. So I have to grep the value of xmldefaulttimeout and replace it with another given value (for example:4.0).
I think I have to use sed or awk. But I’m sorry my tried commands can’t realize this.
Could anybody help me with this? Thanks!
I’m sorry I just begin to learn shell:-)
To match any value for xmldefaulttimeout you’ll have to use a regex:
xmldefaulttimeout=\"[0-9.]*\"xmldefaulttimeout=: Matchedliterally
\": To match a literal", you needto escape the
"to preventpremature ending of the pattern.
[0-9.]: Char class to match anydigit or a period
*: zero or more of the previous char.