LoginSignup
2
2

More than 5 years have passed since last update.

grepの基本的な使い方

Last updated at Posted at 2018-01-28

grepとは

global regular expression printの略
ファイルの中の文字列を検索する。

基本コマンド

grep "検索文字列" ファイル名
grep "正規表現" ファイル名

拡張正規表現(ERE)を使うときは -E()オプションをつける

grep -E "正規表現" ファイル名

個人的によく使うオプション

-r ・・・ディレクトリを指定する場合。サブディレクトリも検索する。

grep -r "検索文字列" ディレクトリのパス

-i ・・・アルファベットの大文字小文字の違いを無視して検索。

grep -i "検索文字列" ファイル名

-v ・・・指定した文字列を除外してgrep

grep -v "除外したい文字列" ファイル名
2
2
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
2
2