Skip to content

Instantly share code, notes, and snippets.

@roelven
Created November 4, 2010 20:23
Show Gist options
  • Save roelven/663124 to your computer and use it in GitHub Desktop.
Save roelven/663124 to your computer and use it in GitHub Desktop.
Parse .eml files to retrieve emailaddresses
##
## Parse a whole directory of .eml files
## and retrieve all printed emailaddresses, sort them, and remove duplicates
## and print to a file.
##
perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' *.* | sort -u > /tmp/output.txt
@roelven
Copy link
Author

roelven commented Nov 4, 2010

Create a MySQL query to update table later with same expression:

perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "update `kijkmijnhuis` set `unsubscribed` = '1' where `email` = \"$&\"; \n"}' /tmp/output.txt | sort -u > afmeldingen_query.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment