shell脚本:在xml文件中寻找标签中的值

xml文件如下:

》》》》配置文件为config.xml,其/home/huawei/mdn2000/es/conf/config.xml

<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>

比如我们要取出heading标签中的内容,则可以使用如下shell:

conf_file="/home/huawei/mdn2000/es/conf/config.xml"
service_type=`grep DeviceServiceType $conf_file | awk -F ">" '{print $2}' | awk -F "<" '{print $1}'`

猜你喜欢

转载自blog.csdn.net/gramdog/article/details/80355801
今日推荐