shell解析xml

ladofwind 2013-06-20 01:04:25
<?xml version="1.0" encoding="ISO-8859-1"?>
<properties port="10000" URI="tcp://localhost" />

怎么把port的值解析出来
...全文
134 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ladofwind 2013-06-20
  • 打赏
  • 举报
回复
大侠们呢,求指导
ladofwind 2013-06-20
  • 打赏
  • 举报
回复
引用 1 楼 ljc007 的回复:
sed '/port=/!d; s/.*port="\([0-9]\+\)".*/\1/' urfile
如果把这个结果当一个输入呢,不会写了。。 netstat -lnp |grep 9999 这个9999替换成上面的结果port,怎么拼接
ladofwind 2013-06-20
  • 打赏
  • 举报
回复
太强了楼上2位
Carl_CCC 2013-06-20
  • 打赏
  • 举报
回复
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" />
ljc007 2013-06-20
  • 打赏
  • 举报
回复
sed '/port=/!d; s/.*port="\([0-9]\+\)".*/\1/' urfile

19,610

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧