EasyCoding Short Tutorial: Extract E-Mail addresses from a textfile

in email •  9 months ago

Have you ever had the problem that you have a big text file full with user data, but needed only the emails but couldn't extract them quickly?

I definitely did. So I created an easy method to extract all user emails from a textfile.

Open up your console and type/paste the following command:

grep -o '[[:alnum:]+._-]@[[:alnum:]+._-]' FILE.TXT | sort | uniq -i >> Emails.txt

Make sure to replace the FILE.TXT with the name of your text file. You can change the output file by simply changing the filename at the end of the command.

This command will grab all lines in the file which could be an email and put them into another file called "Emails.txt".
No email will ever be listed two times.
You should quickly skim over the output file though since there can be slight mistakes.

Any questions? Leave a comment!

Happy coding!
-PrivateGER

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!