shell sed | awk截取出 xml 中标签的一段 ,万分感谢。

通过shell sed 或者 awk 截取出 如下内容,万谢!!!!!
原文:----》
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<testsuite name="caseflightautomation" timestamp="2015-05-08T11:54:10+08:00" time="55.24840999999999" tests="2" failures="1">

<testcase name="Test_flight_auto" time="38.331098">

<failure>Default: 点击机票模块成功

Default: aaaaa

Default: ssssss

Error: VerboseError: Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().searchBars()[0]</failure>

</testcase>

<testcase name="Test_flight_auto1" time="16.917312">

</testcase>

</testsuite>

通过shell sed 或者 awk 截取出 如下内容,万谢!!!!!
想要的结果 ---》
<testcase name="Test_flight_auto" time="38.331098">
<failure>Default: 点击机票模块成功
Default: aaaaa
Default: ssssss
Error: VerboseError: Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().searchBars()[0]</failure>
</testcase>
<testcase name="Test_flight_auto1" time="16.917312">
</testcase>

sed -n '/<testcase/,/<\/testcase/p' 4.txt


假设文本在4.txt中

温馨提示:答案为网友推荐,仅供参考
相似回答