Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.