3

So I have a long list of email and I want to search these based on just a few sections of the email string.

I want to try and search these emails more efficently so I want to match the start of the email. Is there a simple way to match the first character/first few characters, the @ and the following character and end of the email.

Here's an example search:

cal****@a**m

So then if I used a search on the following list it would only pull the top 2

callum@aol.com
callumsmith@aol.com
callumfrrg@test.com
someemail@test.com
Olorin
  • 4,656
Callum
  • 133

1 Answers1

7

With grep:

grep '^cal.*@a.*m$' input.txt

This matches lines beginning ^ with cal, followed by anything (.*), followed by @a, again followed by anything, with m at the end ($).

Olorin
  • 4,656