Fedora Linux Support Community & Resources Center
  #1  
Old 17th October 2005, 12:58 AM
TreasonX Offline
Registered User
 
Join Date: Sep 2005
Posts: 27
Email and Grep

I recently had to pull a bunch of email addresses from a txt file with a bunch of mixed lines of text. Im really new to grep so it took me sometime and I finally got it to work almost perfect. It spit out the name and email address when ever it found an @ symbol. I was just wondering is there a better way to do this and am I on the right track?

Here is an example of the text file lines.. The have been edited to protect the innocent:


Code:
> Tom ( tom@blahblah.org ntohing),
>
> Julie yyum (jblizzzab@comcast.net, jull_assn@post.smoeschool.edu, but
> doesn't check email regularly; I have her phone number if necessary),
>
> Julia (julia@rabloappoosen.org , lj=stawelcomester),
>
> Jim ( mooper@aol.net, lj=mmmooyyeqt) and Honey
> ( honey@raverscene.net, honeyb@rigo.film.org, honeyb@film.org ,
> lj=lfunnybutone),
Here is the grep that I came up with:


Code:
[James@treasonx ~]$ grep -o '[a-Z].*@*.com\b' email.txt > address_com.txt
[James@treasonx ~]$ grep -o '[a-Z].*@*.org\b' email.txt > address_org.txt
[James@treasonx ~]$ grep -o '[a-Z].*@*.edu\b' email.txt > address_edu.txt
[James@treasonx ~]$ grep -o '[a-Z].*@*.net\b' email.txt > address_net.txt
[James@treasonx ~]$ grep -o '[a-Z].*@*.gov\b' email.txt > address_gov.txt
And here is the output I got well an example of what it looked like:



Code:
Mike (mikers@alumni.mit.edu
Julie (jukilfunab@comcast.net
Jim ( jnoobes@myplace.net
honey@raverscene.net
It took me about 15 minutes to get this to work.. Is this the easiest way or did I kill myself doing it this way? Also I would have liked to just get the email addresses but getting the names before them was an added bonus. How could I have just gotten the email address?
Reply With Quote
  #2  
Old 17th October 2005, 06:23 AM
Jman Offline
Registered User
 
Join Date: Mar 2004
Location: Minnesota, USA
Age: 27
Posts: 7,909
I don't know, I need to learn more regular expressions.

But here's a tool that should extract email addresses.
Reply With Quote
  #3  
Old 17th October 2005, 02:24 PM
TreasonX Offline
Registered User
 
Join Date: Sep 2005
Posts: 27
Thats exactly what I wanted.. Now how did they do that
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Evolution Email when Connecting to email server through dialup tmort Using Fedora 0 12th February 2007 11:30 PM
"grep" username in samba or grep file owner? overlord Servers & Networking 0 22nd July 2005 02:12 PM
Combine email in Outlook express with an email-client in Linux TMH Using Fedora 5 22nd December 2004 11:36 PM


Current GMT-time: 18:42 (Saturday, 25-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat