shell 解析 xml
场景:
shell解析xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<properties port="10000" URI="tcp://localhost" />
怎么把port的值解析出来
------解决方案--------------------
------解决方案--------------------
cat file.xml
------解决方案--------------------
grep "port="
------解决方案--------------------
awk -F "\"" '{print $2}'
file.xml里面的内容就是
<?xml version="1.0" encoding="ISO-8859-1"?>
<properties port="10000" URI="tcp://localhost" />
shell解析xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<properties port="10000" URI="tcp://localhost" />
怎么把port的值解析出来
------解决方案--------------------
sed '/port=/!d; s/.*port="\([0-9]\+\)".*/\1/' urfile
------解决方案--------------------
cat file.xml
------解决方案--------------------
grep "port="
------解决方案--------------------
awk -F "\"" '{print $2}'
file.xml里面的内容就是
<?xml version="1.0" encoding="ISO-8859-1"?>
<properties port="10000" URI="tcp://localhost" />