Parsing email addresses out of strings & files with grep or egrep and a regular expression

 

grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+\b" filename.txt

You can also use egrep instead of grep with the -E switch.

egrep -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+\b" filename.txt

Leave a Comment

Scroll to Top