-   Linux - Newbie (
-   -   Grep Recursive Search Results Send To E-mail or Log? (

Knucklehead00 06-05-2009 10:06 AM

Grep Recursive Search Results Send To E-mail or Log?
Hey all.

I am still working my around with Linux commands.

I was able to put together some code that found the occurence of a text phrase. The output came back perfect.

Now, I need to run the command again and either have it send the results to my e-mail or to a log file that I can download.

Here is the command I was using:


grep -rH "mysql_connect" ./public_html/*
Any help is appreciated.


jimbo1708 06-05-2009 10:09 AM

try this


grep -rH "mysql_connect" ./public_html/* >> output.dat
or if you have an email server set up on your machine


grep -rH "mysql_connect" ./public_html/* | sendmail
Corrected pipe as per druuna's recommendation. I guess I wasn't thinking

druuna 06-05-2009 10:19 AM


grep -rH "mysql_connect" ./public_html/* || sendmail
That is not correct, hopefully a typo but there should be 1 pipe character not 2.

grep -rH "mysql_connect" ./public_html/* | sendmail

Depending on your setup (sendmail doesn't send mail from/to local lan on my boxes) you can also try mail or mailx (syntax is the same).

All times are GMT -5. The time now is 10:21 PM.