If this question has been asked and answered before, my apologies. I couldn't find anything from looking.
How can I use linux grep / regex to find unknown characters in an email address? For example, let's say we had this list:
userone:[email protected]
usertwo:[email protected]
userthree:[email protected]
how could I grep the list to find emails matching ***@example.com?
(the only email that should be found from this is [email protected])
I'm aware that grep -e '...@example\.com' would work, but periods can represent any characters in grep, so doing this would also find :[email protected]. Plus, MOST email address don't contain just any character, they are typically confined to letters, numbers, periods, and underscores (many email providers don't allow anything else)
I need to use something else besides a period symbol in grep, something like [a-Z0-9._] so that letters, numbers, periods, and underscores are included but nothing else. I'm unsure of how to go about this. Thanks
EDIT: What I've tried so far:
grep -e '[a-zA-Z0-9_.]{3}@example.com' *. This doesn't work, so it comes down to just me getting the regex wrong.
\.. Your question seems to have to do with regex basics. I would suggest looking at an informational site such as regular-expressions.info or experimenting on regex101.com. - CAustin+in email addresses. See regular-expressions.info/email.html - Stephen Pgrep '[email protected]'then. you do not need any regular expression. - Serge