I wish to use a grep search to find the string 'base64' in any/all php files in a folder (and its subfolders) saved on my mac's desktop. I'm not very experienced using the Terminal command line functions. I've written
grep -lr base64 *.php but this only finds the relevant php files in the folder, not its subfolders. What is the correct command to show every php file I'm looking for?
12 Answers
You could use the --include option of grep
grep -lr base64 --include=*.php Yup. Thanks @Clearquestionwithexamples
find . -iname "*.php" -exec grep -Hi base64 {} \;
That seems to be the answer to what you're looking for (search for "base64" in *.php files), and is based on some of the available answers in referenced resources.
If you have a directory that just has *.php files, you can use this even-easier syntax:
grep -iR base64
To just “show every php file I'm looking for” (and not bother with looking for “base64”), you can do that with simply:
find . -iname "*.php"