Option
| option | mean |
|---|---|
| -r | 再帰的に grep コマンドを実行する |
| —include=*.rb | 指定ファイルのみ検索 |
| —exclude-dir=test | 指定フォルダを除外 |
| -w | 単語としてマッチする場合(IDE の whole words only) |
| -e | 検索パターン 検索パターンを指定 |
| -G | 基本正規表現を使う |
| -E | 拡張正規表現を使う |
| -P | Perl 正規表現を使う |
| -i | 大文字小文字区別しない |
| -w | Matches only word/words instead of substring. |
| -v | マッチしない形を検索結果になる |
| -n | 行番号を表示する |
検索
grep <search_word> <file_name>AND 検索
grep <search_word> <file_name> | grep <search_word>複数条件
grep "aaa\|bbb" test.txtパタ-ン検索
grep -rnw ./ -e "pattern"-v マッチしない
grep -v -e '^\s*#' -e '^\s*$' filenameディレクトリ指定
grep -r "検索文字列" ディレクトリのパス大文字小文字無視
grep -i "検索文字列" ファイル名