我有一个名为 compare.txt
的文本文件,其中我想提取包含模式 nmse_gain_constant
的每一行后面的一行。下面的命令让我靠近:
grep -A 1 nmse_gain_constant compare.txt | grep -v nmse_gain_constant
但是,这包括一个分隔符 --
行之间的每一行所需的文本。有什么简单的办法可以去掉 --
线吗?
示例: 输入文件类似于
line
line
nmse_gain_constant matching line
line after first match
line
line
nmse_gain_constant another matching line
line after second match
line
nmse_gain_constant a third matching line
line after third match
输出是
line after first match
--
line after second match
--
line after third match
但我希望
line after first match
line after second match
line after third match