如何反向使用grep?

如何反向使用grep?

我想做与 grep 相反的事情。我想排除具有特定模式的输出行。

我想要的是一个命令“ngrep”:

$ output
hi how are you?
hi hi haw are you?
hu hi how are you?
haw haw haw are you?

$ output | ngrep 'haw' :
hi how are you?
hu hi how are you?

答案1

grep 手册页:

   -v, --invert-match
          Invert the sense of matching, to select non-matching lines.

相关内容