Shell, Unix, grep -v



我知道我们可以在shell中执行grep -v。我知道我们可以做grep -A2

我们能做grep -v -A2吗?

我想删除连续的2行。就像grep -A2一样。

如何进行grep-v(2行(?

输入文件

Eat rice
14677
Go school
1245677

输出文件

Go school
1245677

易于使用sed:

$ cat input.txt
Eat rice
14677
Go school
1245677
$ sed '/Eat rice/,+1d' input.txt
Go school
1245677

删除所有与Eat rice匹配的行和下面的行,打印其余行。

最新更新