Grep Search all files in directory for string1 AND string2

前端 未结 8 461
迷失自我
迷失自我 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:57

    Do you mean "string1" and "string2" on the same line?

    grep 'string1.*string2'
    

    On the same line but in indeterminate order?

    grep '(string1.*string2)|(string2.*string1)'
    

    Or both strings must appear in the file anywhere?

    grep -e string1 -e string2
    

提交回复
热议问题