Skip to content

Instantly share code, notes, and snippets.

@martinmev
Created September 16, 2012 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinmev/3731861 to your computer and use it in GitHub Desktop.
Save martinmev/3731861 to your computer and use it in GitHub Desktop.
Script gets email addresses from the text (first argument). Emails are written to the output file (second argument).
#!/usr/bin/env python
import sys
import re
getEmails = re.compile(r'[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}')
content=open(sys.argv[1],'r').readlines()
found = set()
for c in content:
found.update(getEmails.findall(c))
out = open(sys.argv[2],'w')
for f in found:
out.write(str(f)+'\n')
out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment