Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Regex - pulling only unique strings from files

Posted on 2005-03-16
2
Medium Priority
?
479 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
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

Technology Partners: 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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Screencast - Getting to Know the Pipeline

581 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