?
Solved

Regex - pulling only unique strings from files

Posted on 2005-03-16
2
Medium Priority
?
477 Views
Last Modified: 2012-08-14
Hello,

I'm writing a regex to pull e-mail addresses from some files to be used for a spam filter whitelist. I've gotten it to pull all e-mail addresses from the file(s). I am wondering if it's possible to only pull unique e-mail addresses from the file? Right now it pulls all e-mail addresses.

Here's what I'm using:

grep -e '^From:' | grep -e '[A-Za-z0-9\.]*@[A-Za-z0-9][^mydomain.com][^MYDOMAIN.COM]*\.[A-Za-z0-9]*' -o

Thanks,
Rod
0
Comment
Question by:reason100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
mattchssm earned 500 total points
ID: 13561681
You could try

grep -e '^From:' | grep -e '[A-Za-z0-9\.]*@[A-Za-z0-9][^mydomain.com][^MYDOMAIN.COM]*\.[A-Za-z0-9]*' -o | sort -u

although that would have the side-effect of sorting your list.
0
 
LVL 1

Author Comment

by:reason100
ID: 13575781
Thank you, I didn't think of that. I don't mind at all that it sorts the list as well.

Rod
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question