<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tasks xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="modelSchema.xsd">
<task id="OPER_FAILCAUSE_TASK_1" business="OPER_FAILCAUSE" period="5Min" enabled="true" persistence="true" condition="" >
<dimensionIds id="STARTTIME" />
<counterIds id="MAX_PD"/>
</task>
</tasks>
以上xml,读取后输出结果如下(只读取task节点中的字段):
OPER_FAILCAUSE_TASK_1,OPER_FAILCAUSE
就输出这两个值,谢谢!!!
或者:
或者:
sed -n '/task id/{s/"//g;s/^ *//;p}' test.xml | awk -F"[= ]" '{print $3","$5}'执行结果为:
OPER_FAILCAUSE_TASK_1,OPER_FAILCAUSE
希望对你有所帮助!