LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep script (https://www.linuxquestions.org/questions/linux-newbie-8/grep-script-501588/)

kaiserbeto 11-14-2006 03:32 PM

grep script
 
Hello!

I'm trying to write a script that goes through my /var/spool/mail/<user> file to grep out specific error codes and dump the e-mail address associated with that error into our unsubscribe database.

So my problem (and lack of BASH knowledge) comes in when i'm trying to grep both the error code AND the e-mail address associated with it. For example :


----- The following addresses had permanent fatal errors ---

<user@domain.com>

(reason: 550 Command rejected for policy reasons. For troubleshooting information, go to http://postmaster.msn.com)

So, I know how to grep for the error codes, but how do I snag the e-mail address along with it. I'm guessing i have to use sed and awk, but i'm not entirely sure which pattern matching expression to use to do this. Thanks!

homey 11-14-2006 03:42 PM

Maybe something along this line....
Code:

sed -n '/<tom/,/\.com)/p' file.txt

jonwatson 11-15-2006 01:50 PM

I have to learn more about sed and awk. They seem just freaking awesome...


All times are GMT -5. The time now is 02:40 PM.