来自以下xml:
<?xml version="1.0"?>
<broker xmlns="some-ns.com" name="some-ns">
<queue name="US.PUT.INTERNAL.FULFILLMENT.REMEDY" enable="true" process="/u/is/bin/RmdyCrtUtil.sh" />
<queue name="US.DATA.MINING.IN" enable="true" process="/u/is/bin/ferret_trigger" />
<queue name="US.PHOTO.INPUT" enable="true" process="/u/is/bin/spx0400b.sh" />
<queue name="US.OPTICAL.INPUT" enable="true" process="/u/applic/optical/svc_web_proc.sh" />
<queue name="US.TLGO.DATA.QUEUE" enable="true" process="/u/is/smb0010b.sh" />
</broker>
我想提取以下内容:
US.PUT.INTERNAL.FULFILLMENT.REMEDY
US.DATA.MINING.IN
US.PHOTO.INPUT
US.OPTICAL.INPUT
US.TLGO.DATA.QUEUE
/u/is/bin/RmdyCrtUtil.sh
/u/is/bin/ferret_trigger
/u/is/bin/spx0400b.sh
/u/applic/optical/svc_web_proc.sh
/u/is/smb0010b.sh
答案 0 :(得分:0)
对于给定数据和即时解决方案,您可以使用:
cat test.xml |grep '<queue'|cut -d '"' -f2
- 会给您name
值
cat test.xml |grep '<queue'|cut -d '"' -f6
- 会为您提供process
值
$ cat test.xml |grep '<queue'|cut -d '"' -f2;cat test.xml |grep '<queue'|cut -d '"' -f6
US.PUT.INTERNAL.FULFILLMENT.REMEDY
US.DATA.MINING.IN
US.PHOTO.INPUT
US.OPTICAL.INPUT
US.TLGO.DATA.QUEUE
/u/is/bin/RmdyCrtUtil.sh
/u/is/bin/ferret_trigger
/u/is/bin/spx0400b.sh
/u/applic/optical/svc_web_proc.sh
/u/is/smb0010b.sh