JasonDaly.name

PHP, Ruby, Symfony, Rails, Doctrine, MooTools. Web Development.

Posts tagged with "email"

February 26, 2010

Parsing Email Addresses From a Log File

Recently I needed to parse all unique email addresses from a very large plaintext log file. A simple grep would not suffice because there were many cases where multiple email addresses appeared on the same line.

Realizing there are many solutions to this problem, here is the one I came across1 which I found most suitable for my needs.

perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' path/to/log_file | sort -u > parsed_unique_sorted_emails.txt

2 notes Tags: perl bash email parsing tips