grep コマンドで文字列(パターン)を複数指定して(OR)検索する

published: 2019.03.11 / modified:

grep コマンドで、複数のパターンを指定して検索する。

grep コマンド

grep は、ファイルの中の文字列を検索するコマンド。

grep コマンドで複数の文字列を検索

-e オプションを使って、複数の文字列を検索対象にする。
次の例では、 'hoge' もしくは 'huga' が含まれている行が表示される。

$ grep example.txt -e 'hoge' -e 'huga'

Previous Article

Next Article