Filter email addresses with egrep

You can use the following command to filter email addresses from text:

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

For example, to get email addresses of all users with wp-cli:

$ wp user list | egrep -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b"

Cool huh?!

Comments