Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-14-2006, 03:32 PM   #1
LQ Newbie
Registered: Oct 2006
Posts: 10

Rep: Reputation: 0
grep script


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

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!
Old 11-14-2006, 03:42 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Maybe something along this line....
sed -n '/<tom/,/\.com)/p' file.txt
Old 11-15-2006, 01:50 PM   #3
Registered: Jun 2004
Location: Nova Scotia, Canada!
Distribution: Ubuntu
Posts: 170

Rep: Reputation: 30
I have to learn more about sed and awk. They seem just freaking awesome...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
grep script/syntax carriehoff Linux - Newbie 6 08-31-2006 01:13 PM
Shell script with grep MicahCarrick Programming 4 08-15-2006 01:08 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
bash script and grep syros Programming 4 01-13-2005 03:04 PM
sed & grep script? dolvmin Linux - Software 20 09-22-2003 06:30 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration