Skip to content

Instantly share code, notes, and snippets.

@wm
Last active August 29, 2015 14: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 wm/4ba770e9e8a849f1348a to your computer and use it in GitHub Desktop.
Save wm/4ba770e9e8a849f1348a to your computer and use it in GitHub Desktop.
Extract uniq emails sorted by domain from file.

Extract uniq emails sorted by domain from file.

Note that we ignore emails of the form xxx@yyy.com, i.e. if it has a '<' we ignore it.

Usage

$ extract_emails.zsh file_with_emails.txt
example@example.com
ex@ex.com
...
# Extract uniq emails sorted by domain from file.
# Note that we ignore emails of the form <xxx@yyy.com>, i.e. if it has a '<' we ignore it.
awk '{
for (i=1;i<=NF;i++) {
if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) {
print $i
}
}
}' $1 | sort | uniq | grep -v '<' | sort -t@ -k2 -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment