I'd like to find all files that contain a certain string of text. How would you do that in the Terminal?
Ignacio's Answer is great and helped me find the files containing certain text. The only issue I was facing was that when running this command all the files would be listed, including one where the pattern did not show up.
No such file or directory This is what I see alongside files that do not contain the pattern.
If instead you add
-s to the command, as in:
grep -lr "text pattern" ./ -s ;
grep -lr "text pattern" [PATH DIRECTORY] -s is used, it will only show you which files contain the pattern.
grep -nr "text pattern" ./ -s ;
grep -nr "text pattern" [PATH OF DIRECTORY] -s command is used it prints the file plus the line number, and occurrence of the pattern.
Please correct me if my understanding is wrong.