Skip to content

Instantly share code, notes, and snippets.

@micc83
Last active May 10, 2017 10:06
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 micc83/88c011c8d363f43bc91836981d150bee to your computer and use it in GitHub Desktop.
Save micc83/88c011c8d363f43bc91836981d150bee to your computer and use it in GitHub Desktop.
Find email address in a given file
grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" file.txt
or even better:
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | sort | uniq > emails.txt
all lowercase:
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | tr "[:upper:]" "[:lower:]" | sort | uniq > emails.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment