shell解析xml文件
1.yum install libxml2 安装类库
2.xmllint --xpath "/books/book[@id=2]/text()" 获得目标标签值
<
books
>
<
book
id
=
"1"
>
<
name
>book1</
name
>
<
price
>100</
price
>
</
book
>
<
book
id
=
"2"
>
<
name
>book2</
name
>
<
price
>200</
price
>
</
book
>
<
book
id
=
"3"
><
name
>book3</
name
><
price
>300</
price
>
</
book
>
</
books
>
参考文档:https://www.jb51.net/article/125887.htm