linux list file names with certain strings in the file content

The first command was found on the Internet:
find .|xargs grep -ri "string to look for" -l
This command has a problem, it will list the file names that meet the conditions twice.

The second command is a friend Gives :
grep "string to find" ./ -Rn -l

This is correct, exactly half as many as the first command

If you want to list the filenames of files whose contents contain 2 strings:
grep "to find The string 1" ./ -Rn | grep "the string you want to find 2" ./ -Rn -l

more than two and so on


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326779675&siteId=291194637