Extract Email Addresses from Text Files on Linux

Was looking for a quick way to extract email addresses only from a folder full of csv files. Perl to the rescue Ijust did this

cat *.csv > all.csv
perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' all.csv | sort -u > output.txt

Presto a nice alphbetical list of email addreses ripped from the beating heart of the csvs.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s