GREP Command to Extract Email Addresses from EML Files

I have a directory with thousands of EML files that are essentially bounce messages. I want to extract all of the email addresses from these bounce messages to make changes to the relevant accounts.

This can be done with grep but navigating to the directory where all the EML files are located and then:

grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' *.eml | sort | uniq -i > emails.txt

Leave a Reply