Grep Search all files in directory for string1 AND string2

前端 未结 8 463
迷失自我
迷失自我 2020-12-31 02:22

How can I make use of grep in cygwin to find all files that contain BOTH words.

This is what I use to search all files in a directory recursively fo

8条回答
  •  暖寄归人
    2020-12-31 02:49

    The uses PCRE (Perl-Compatible Regular Expressions) with multiline matching and returns the filenames of files that contain both strings (AND rather than OR).

    grep -Plr '(?m)db-connect\.php(.*\n)*version|version(.*\n)*db-connect\.php' .
    

提交回复
热议问题