阅读两个关键字之间的行 [英] Read lines between two keywords

查看:104
本文介绍了阅读两个关键字之间的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人建议,如果我有像

*System_Power
1
1.2
1.8
2
*System_Terminate

在这种情况下,asnwer将是

In this case the asnwer would be

1
1.2
1.8
2

我试着用awk像

I tried using awk like

awk '$0 =="*System_Power"               #  start printing when 1st field is *System_Power
$0 != "*System_Terminate"{              #  until reach the  *System_Terminate
print;   } ' powerSummary > reportedFailure.k    # Read from file powerSummary and pipe to reportedFailure.k
exit

当上述数据以文件powerSummary中间的某处找到。

where the above data is found somewhere in the middle of file powerSummary.

我会很感谢你的更正。

推荐答案

这会为你工作:

$ awk '/\*System_Power/{f=1;next}/\*System_Terminate/{f=0}f' infile
1
1.2
1.8
2

这篇关于阅读两个关键字之间的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆