Match email address

If you have a file with several lines that contains email addresses that you like to extract, you can do that with Linux grep command:

File “emails.txt”:

somestreng anotherstring 342345

where is the string you like to extract:

you can do this with:

grep -EiEio '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b' emails.txt


Leave a Reply

Your email address will not be published. Required fields are marked *