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.

おすすめ記事