GREP syntax for email addresses?
Posted on 2007-03-30
What is the best GREP syntax to select an email address? In the file(s) I'm searching (using Terminal in Mac OS X ... uses bash), I want it to select just the e-mail address in the only line in the file that *begins* with an e-mail address, such as:
<firstname.lastname@example.org>... Deferred: Connection timed out with msn.net.
<email@example.com>... Deferred: Connection timed out with human.co.uk.
<firstname.lastname@example.org>... Deferred: 452 4.2.2 Message would exceed quota
IOW I want the grep to select just "email@example.com" or "firstname.lastname@example.org" etc. I don't want the < and the > and I don't want anything else on the line.
I already know how to tell it to find the line itself, remove dupes and put it in a text file:
| grep "^<" | sort -u > ~/Desktop/bounces.txt
but as I said, I just want the actual email addy's, not the whole line, added to bounces.txt.