LoginSignup
1
0

More than 5 years have passed since last update.

grepを使った検索結果で表示されるファイルの数を数える

Posted at

この記事の内容を一言で

$ grep -R "*" (ディレクトリ)  | grep -v "*" | wc -l

grep -R "*" (ディレクトリ)

(ディレクトリ)以下のディレクトリから、"*"の内容が完全に一致した文字列を含んだファイルを表示する

grep -v "*"

"*"を含むファイルを検索結果から除外する

wc -l

検索結果のファイルの数を数える

まとめ

$ grep -R "1" (ディレクトリ)  | grep -v "2" | wc -l

"1"と完全一致した文字列を含んだ(ディレクトリ)以下のファイルから、"2"と同じ文字があるファイルを除外し、その数を数える。

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