ham*_*han 6 linux bash awk sed
如果我必须在两个关键字之间阅读,有人可以建议做什么
*System_Power
1
1.2
1.8
2
*System_Terminate
Run Code Online (Sandbox Code Playgroud)
在这种情况下,asnwer将是
1
1.2
1.8
2
Run Code Online (Sandbox Code Playgroud)
我试过用awk之类的
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
Run Code Online (Sandbox Code Playgroud)
其中上述数据位于文件powerSummary中间的某处.
我会感谢您的更正.
这对你有用:
$ awk '/\*System_Power/{f=1;next}/\*System_Terminate/{f=0}f' infile
1
1.2
1.8
2
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3638 次 |
最近记录: |