LoginSignup
1
4

More than 3 years have passed since last update.

grepコマンド

Last updated at Posted at 2019-07-16

grep

grep は特定の文字列を含むファイルの検索ができる。

xargsとの併用に関しては別スレッド。

$ grep [検索正規表現] [option] [directory] 

[検索正規表現] [option]については順不同。

ディレクトリは、例えば現階層のファイル全てから検索であれば./*で検索。

オプションは主に使うものだけ以下にメモ

#大文字と小文字を区別せず検索
$ grep [検索正規表現] -i [directory] 

#一致しないものを検索
$ grep [検索正規表現] -v [directory] 

#行番号と併せて表示
$ grep [検索正規表現] -n [directory] 

#ファイル名のみ表示
$ grep [検索正規表現] -l [directory] 

#ディレクトリ内も検索に含める
$ grep [検索正規表現] -r [directory] 
1
4
0

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
1
4