25
18

More than 5 years have passed since last update.

特定の文字列を含まないファイルを検索する

Posted at

下記のように、tomという文字列を含む"a.txt"と"b.txt"、
hanakoという文字列を含む"c.txt"があるとします。

*:test$ cat a.txt b.txt c.txt 
tom is boy
tom is 13 years old
hanako ha kawaii

この場合に、tomを含むファイルを検索する場合は

grep -r tom ./*

としますが、逆にtomを含まないようなファイルを検索したい場合は

grep -L tom ./*

=> ./c.txt

こうすれば検索することが出来ます。

25
18
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
25
18