我需要从下面的报告中提取“Timing exception”和“---------”之间的界限,然后将它们输出到文件
Timing exceptions with no effect exception's
report timing -paths [eval [::legacy::get_attribute paths <exception>]]
/designs/exceptions/path_groups/
-----------------------------------
Summary
Loop-breaking cells for combinational feedback 0
Nets with multiple drivers 0
Timing exceptions with no effect 5
Suspicious multi_cycle exceptions 0
Outputs without clocked external delays 0
Total: 5
我试过了
sed -n '/Timing exceptions/,/-----/p' filename
,但它总是返回
Timing exceptions with no effect exception's
report timing -paths [eval [::legacy::get_attribute paths <exception>]]
/designs/exceptions/path_groups/
-----------------------------------
Timing exceptions with no effect 5
Suspicious multi_cycle exceptions 0
Outputs without clocked external delays 0
Total: 5
我只想要上面4行,但我不知道如何摆脱下面的线条。有人可以帮帮我吗?非常感谢你!
答案 0 :(得分:4)
在^
之前添加Timing exceptions
以表示该行的开头:
sed -n '/^Timing exceptions/,/-----/p' file.txt
您有Timing exceptions
两行,一个在第一行,另一行在----
行之后,因此您获得两个块,一个用于第一个到----
行,另一个从第二个Timing exceptions
到最后,因为之后没有----
行。
我们在^
之前使用了Timing exceptions
,因此我们只能匹配第一个块,而Timing exceptions
不会出现在第二个块中。
示例:强>
% sed -n '/^Timing exceptions/,/-----/p' file.txt
Timing exceptions with no effect exception's
report timing -paths [eval [::legacy::get_attribute paths <exception>]]
/designs/exceptions/path_groups/
-----------------------------------
答案 1 :(得分:0)
awk
的替代方法。
awk '/^Timing exceptions/,/-----/' infile
Timing exceptions with no effect exception's
report timing -paths [eval [::legacy::get_attribute paths <exception>]]
/designs/exceptions/path_groups/
-----------------------------------