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 ---
(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!