我需要在ec2-instance中运行用户数据脚本,该脚本更改文件夹中的XML。从脚本编辑xml
我有这样一个在路径中EC2的XML:
<Root>
<Properties>
<Property>
<Name>myProp</Name>
<Value>old_value</Value>
</Property>
<Property>
<Name>anotherProp</Name>
<Value>other_value</Value>
</Property>
</Propierties>
</Root>
我想改变OLD_VALUE到NEW_VALUE。但只是那一个,不是other_value。
我该怎么做?
我已经尝试了的PowerShell脚本,但我不知道如何运行它来测试它:
#!/bin/bash
$path = '/home/wowza/conf/Server.xml'
$new_value = 'new_value'
$xml = [xml](Get-Content $path)
$xml.Data.Course.Subject
$property = $xml.Root.Server.Properties.Property | where {$_.Name -eq 'myProp'}
$property.Value = $new_value
$xml.Save($path)
请你给我一个脚本,不要忘了包括如何运行它来测试它,#的解释器!线和安装什么东西。 谢谢!
这可能会有所帮助:[使用xmlstarlet,如何更改元素的值](http://stackoverflow.com/q/35636357/3776858) – Cyrus