Skip to content

Instantly share code, notes, and snippets.

@EnriqueVidal
Created April 4, 2012 18:50
Show Gist options
  • Save EnriqueVidal/2304702 to your computer and use it in GitHub Desktop.
Save EnriqueVidal/2304702 to your computer and use it in GitHub Desktop.
Extract emails from files
#!/usr/bin/env bash
function email_extract {
if [ -z "$1" -o -z "$2" ]; then
echo usage: email_extract path file
echo example: email_extract . *.php
return 1
fi
find $1 -iname $2 -exec perl -wne'while(/[\w\.]+@[\w\.\-]+\w+/g){print "$&\n"}' {} \;
}
email_extract $1 $2
#vim: set ft=sh
@EnriqueVidal
Copy link
Author

Just give it execution permission and put it somewhere in your $PATH

@EnriqueVidal
Copy link
Author

Actually don't use this, use ack ack -i '[\w\.]+@[\w\.\-]+[a-z]{2,3}+' -o --no-filename | sort | uniq or rewrite it and make it ignore comments.

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