0
1

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.

よく使うgrepコマンド集

Last updated at Posted at 2019-03-31

こちらの記事から切り出し

カレント配下の(.)マッチするファイル内文字を、再帰的に検索し(-r)、行番号も表示する(-n).
grep -rn "対象文字列" .
カレント配下の(.)マッチするファイル内文字を、再帰的に検索し(-r)、行番号と合致行に隣接する下の行(-A)を表示する(-n).
grep -rn -A数字 "対象文字列" .
カレント配下の(.)マッチするファイル内複数文字(|)を、再帰的に検索し(-r)、行番号も表示する
grep -rn "検索文字1\|検索文字2" .
カレント配下の(.)マッチするファイル内複数文字(|)を、再帰的に検索し(-r)、行番号を表示する
grep -rn "検索文字1" . | grep "検索文字2"
カレント配下の(.)マッチするファイル内文字を、再帰的に検索し(-r)、出力行をファイルに吐き出す.
grep -r "対象文字列" . > hoge.txt
特定のファイルのマッチするファイル内文字の出力行をファイルに吐き出す.
grep "対象文字列" ファイル名 > hoge.txt
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?