shell 修改xml文件 的参数值。

来源:互联网 发布:微信公众号淘宝优惠券 编辑:程序博客网 时间:2024/06/10 01:19
http://www.cnblogs.com/zhonghan/archive/2012/11/01/2749860.html
setParameter.sh 

#!/bin/sh

 
if [ $# -eq 3 ]; then
    sed -i 's/<'"$1"\>'.*</<'"$1"'\>'"$2"'</g' $3
else
   echo error
fi

 原始xml文件:

/home/test.xml

 <cellphone>

<android>1000</android>

 <apple>200</apple>

</cellphone> 

 

 执行命令

 ./setParameter.sh  apple 800 /home/test.xml

 修改后的xml文件:

/home/test.xml

 <cellphone>

<android>1000</android>

 <apple>800</apple>

</cellphone>  


0 0
原创粉丝点击