shell 修改xml文件 的參數值。

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>  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章