4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

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

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

1 upvotes $0.00

Replies (2)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: