更新时间:2023-12-03 18:28:40
这可能对你有用(GNU sed):
This might work for you (GNU sed):
sed -n ':a;$!{N;s/\n/&/2;Ta};/^PATTERN\'\''/MP;$!D' file
这将打印整个文件中 PATTERN 之前的第 2 行.
PATTERN
This will print the line 2 lines before the PATTERN throughout the file.
SED:在匹配前寻址两行
正则表达式仅在类匹配首次出现之前进行匹配
用grep在一行中匹配两个字符串
测试两列字符串在R中匹配行
如何在第一个匹配的地址范围后退出 sed?
使用sed删除匹配的正则表达式及其下一行(或两行)
Sed:在匹配前打印 2 行