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}'`

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