I'm trying to get the email addresses from a file using egrep -o -e
and having trouble with addresses at the end of a line.
Here is my regex:
egrep -o -e "[._a-zA-Z0-9]+@[._a-zA-Z0-9]+.[._a-zA-Z0-9]+" ~/myfile.txt
I realize this will not catch every variation of an email address, but if the address is at the end of a line this is what I get:
user@_12345@myemail.com\ul
So I figured I'd try a negative lookahead, but I have no idea how to properly use it. I've read a few things online but I'm confused by how it works.
This is what I've tried:
egrep -o -e "(?!\\[._a-zA-Z0-9]+@[._a-zA-Z0-9]+.[._a-zA-Z0-9]+)" ~/myfile.txt
Bash fails with event not found: \\[._a
Any suggestions?