PDA

View Full Version : Searching entire root directory for mail() function inside files



jhen123
04-11-2008, 02:50 PM
I need to know how to use grep to search my entire directory structure for the mail function so I can make sure someone has not hacked in and put it in a script. I've got probably 300 folders to go through and one at a time isn't going to cut it.

The Bluehost tech sent me a line of code to use in ssh, "find ./ -name \*.php -exec grep -H mail\( {} \;". This searches everything with the word mail in it and it's a pretty long list. I can only see the last 40 lines or so, because there are too many files with the word "mail" in it. I tried to pipe this through less, ex: "find ./ -name \*.php -exec grep -H mail\( {} \ | less;" and I get a syntax error.

I really only need to search for the mail() function. NOT every file with the word "mail" in it. If anyone knows that line of code, please pass it on.

Thanks

IvanAkimov
04-12-2008, 10:47 AM
it looks like you are already searching for "mail(" not just "mail"... would it help if you dump all this info to a file instead of a command window? it would be easier to look at that... :confused: just a suggestion.