LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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

Rep: Reputation: 59
Maybe something along this line....
Code:
sed -n '/<tom/,/\.com)/p' file.txt
 
Old 11-15-2006, 02:50 PM   #3
jonwatson
Member
 
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...
 
  


Reply


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 02:13 PM
Shell script with grep MicahCarrick Programming 4 08-15-2006 02:08 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
bash script and grep syros Programming 4 01-13-2005 04:04 PM
sed & grep script? dolvmin Linux - Software 20 09-22-2003 07:30 AM


All times are GMT -5. The time now is 06:40 AM.

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