LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep Recursive Search Results Send To E-mail or Log? (http://www.linuxquestions.org/questions/linux-newbie-8/grep-recursive-search-results-send-to-e-mail-or-log-730927/)

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:

Code:

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

Thanks.

jimbo1708 06-05-2009 10:09 AM

try this

Code:

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

Code:

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

druuna 06-05-2009 10:19 AM

@jimbo1708:
Quote:

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

grep -rH "mysql_connect" ./public_html/* | sendmail joe.schmoe@domain.com

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 12:07 AM.