96
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【linux】指定した単語を除外してgrepしたい【コマンド】

Posted at

意外と便利なのでメモ:pencil2:

grepコマンドの-vオプション

# grep -v "test"

文字列「test」を除外してgrepしてくれます。
もしかしたら、あまり使う機会はないかもしれないですね・・・。

2つ以上の単語を除外したい時

# grep -v "hoge" | grep -v "fuga"

正規表現を使う方法もありますが、パイプ(半角の|)で区切る方法が手っ取り早い:dash:
なにより、正規表現がわからなくても使えるのがいい!

96
68
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
96
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?