linux - 读取两个关键字之间的行

标签 linux bash sed awk

有人可以建议如果我必须在两个关键字之间阅读时该怎么办吗

*System_Power
1
1.2
1.8
2
*System_Terminate

在这种情况下,asnwer 将是

1
1.2
1.8
2

我尝试像 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

上述数据位于文件 powerSummary 中间的某处。

非常感谢您的更正。

最佳答案

这对你有用:

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

关于linux - 读取两个关键字之间的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9315513/

相关文章:

regex - 如何使用awk或sed,在文中最后一个符号}前添加内容

linux - Bash shell - 按时间顺序统计并显示目录和子目录列表

bash - 如何修改 bash 函数中的全局变量?

bash - 阅读 $OPTARG 以获得可选标志?

linux - SED:显示前 10 行复杂的表达式

node.js - 在 Linux 中安装 Node 和 NPM

linux - 修复在 Kali 中安装 Teensyduino 时加载共享库 : libpng12. so.0 时出现的错误

linux - Bash(薄荷): How to add a newline to a PS3 prompt?

regex - 仅使用 sed 打印二进制匹配?

bash - 计算两个文件中数字的差异