- 论坛徽章:
- 0
|
回复 6# jason680
感谢,%的问题已经解决,但是我的如下文件没修改成功,不知道是什么原因:
awk 'BEGIN{RS="<"}function get_tag(){s=$1;d=sub("^/","",s)?-1:1;if(NF>1){c+=d;if(d>0)t[c]=s}s="";for(n=1;n<=c;++n)s=s"/"t[n];return(s)}{tag=get_tag();if(tag=="/config/interface/system1/reqsystem/address")$2="xxxx";printf "%s",$0RT}' test.xml > tmp
<?xml version="1.0" encoding="utf-8"?>
<config>
<interface>
<!-- Security Center -->
<system1>
<reqsystem>
<address>127.0.0.1</address>
<account>test</account>
<password>test</password>
</reqsystem>
<JK0001>
<api>myApiName1
</api>
<method>POST</method>
<desc>Test Interface</desc>
</JK0001>
<JK0002>
<api>myApiName2</api>
<method>POST</method>
<desc>Test Interface</desc>
</JK0002>
</system1>
<system2>
<reqsystem>
<address>127.0.0.1</address>
<account>test</account>
<password>test</password>
</reqsystem>
<JK0001>
<api>myApiName1
</api>
<method>POST</method>
<desc>Test Interface</desc>
</JK0001>
<JK0002>
<api>myApiName2</api>
<method>POST</method>
<desc>Test Interface</desc>
</JK0002>
</system2>
</interface>
<sysServiceParams>
<info>
<count>10</count>
</info>
<setting>
<about>About</about>
</setting>
</sysServiceParams>
</config> |
|