I'm trying do the following thing: Hunt down all 777 directories, and then within those directories, hunt down those php files which contain the string "mail(". My goal is to make this part of a cron-job which runs every night and finds all of the php files which contain mail functions that may have been inserted surreptitiously onto our server. So, I've written this command:
find -type d -perm 777 -exec find {} -name "*.php" \; -exec grep "mail(" {} \;
Which (is supposed to):
1: find the folders with 777 privileges
2: for each such folder, find all php files contained therein
3: for each such file, perform a grep to find the string "mail("
However, it doesn't appear to be working. What it is doing is giving me a list of php files in 777-privileged directories, but it's not performing the grep. I've looked at some SO postings like this:
find -exec with multiple commands
Which lead me to believe that nesting of -exec is possible. Is there anything obvious I'm missing? Thanks in advance for your time!