【发布时间】:2014-06-26 22:25:04
【问题描述】:
我想替换 XML 文件中的值。示例 XML
<Console>
<!-- REQUIRED PARAMETERS -->
<!-- Enter the node that you are running the installation program from. This value must be a fully qualified name, which includes a host name and domain name. For example, node001.server.name.com.-->
<node>node.sample.ibm.com</node>
<!-- Enter the domain name of the cluster as a single dot-separated string. For example, server.name.com. -->
<sso-domain-name>sample.ibm.com</sso-domain-name>
<!-- Set this property to true if your InfoSphere BigInsights Console uses HTTPS. Otherwise, enter false. -->
<https>false</https>
<!-- management-console-port specifies which port is used by the Management Console. -->
<management-console-port>8080</management-console-port>
我想替换值。 我尝试了以下但它不起作用。任何帮助表示赞赏。
sed -i "/<Console>/,/<\/Console>/ s/<node>[0-9][a-z]\+/<node>newvalue
【问题讨论】:
-
不是您问题的答案。但您也可以在命令行上使用“xmllint”。这直接处理 XML 结构。
-
@Wintermute for simple XML xml2 效果很好
-
这不是重复的,因为 Q 准确地要求
sed