Grep: find all emails that don't have the pattern
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a directory with a bunch of files and each file contains millions of emails.
I need to get all the emails that don't fit with this pattern
x.y@enron.com
x and y are letters.
I have this now but it doesn't match the correct emails
grep -P -r -x (?![a-z]*.[a-z]*@enron)
shell command-line grep regular-expression
 |Â
show 1 more comment
up vote
0
down vote
favorite
I have a directory with a bunch of files and each file contains millions of emails.
I need to get all the emails that don't fit with this pattern
x.y@enron.com
x and y are letters.
I have this now but it doesn't match the correct emails
grep -P -r -x (?![a-z]*.[a-z]*@enron)
shell command-line grep regular-expression
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.
â Jesse_b
May 9 at 14:22
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
1
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a directory with a bunch of files and each file contains millions of emails.
I need to get all the emails that don't fit with this pattern
x.y@enron.com
x and y are letters.
I have this now but it doesn't match the correct emails
grep -P -r -x (?![a-z]*.[a-z]*@enron)
shell command-line grep regular-expression
I have a directory with a bunch of files and each file contains millions of emails.
I need to get all the emails that don't fit with this pattern
x.y@enron.com
x and y are letters.
I have this now but it doesn't match the correct emails
grep -P -r -x (?![a-z]*.[a-z]*@enron)
shell command-line grep regular-expression
edited May 9 at 14:28
ilkkachu
48.1k669133
48.1k669133
asked May 9 at 14:18
Andres ZW
84
84
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.
â Jesse_b
May 9 at 14:22
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
1
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37
 |Â
show 1 more comment
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.
â Jesse_b
May 9 at 14:22
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
1
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:
-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.â Jesse_b
May 9 at 14:22
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:
-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.â Jesse_b
May 9 at 14:22
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
1
1
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
Answer
grep -Evr "[a-z]+.[a-z]+@enron"
Explanation
-E
- Use extended regex. (Allow some characters to be used without escaping them)
-v
- Invert the matches. (Everything that doesn't match the pattern will be shown)
-r
- Search files recursively.
[a-z]+.[a-z]+@enron
- Your regex just with +
instead of *
, as I expect that there must be some letters in each section.
1
This doesn't work at all. Maybe you were looking forgrep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.
â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
 |Â
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Answer
grep -Evr "[a-z]+.[a-z]+@enron"
Explanation
-E
- Use extended regex. (Allow some characters to be used without escaping them)
-v
- Invert the matches. (Everything that doesn't match the pattern will be shown)
-r
- Search files recursively.
[a-z]+.[a-z]+@enron
- Your regex just with +
instead of *
, as I expect that there must be some letters in each section.
1
This doesn't work at all. Maybe you were looking forgrep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.
â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
 |Â
show 3 more comments
up vote
0
down vote
Answer
grep -Evr "[a-z]+.[a-z]+@enron"
Explanation
-E
- Use extended regex. (Allow some characters to be used without escaping them)
-v
- Invert the matches. (Everything that doesn't match the pattern will be shown)
-r
- Search files recursively.
[a-z]+.[a-z]+@enron
- Your regex just with +
instead of *
, as I expect that there must be some letters in each section.
1
This doesn't work at all. Maybe you were looking forgrep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.
â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
 |Â
show 3 more comments
up vote
0
down vote
up vote
0
down vote
Answer
grep -Evr "[a-z]+.[a-z]+@enron"
Explanation
-E
- Use extended regex. (Allow some characters to be used without escaping them)
-v
- Invert the matches. (Everything that doesn't match the pattern will be shown)
-r
- Search files recursively.
[a-z]+.[a-z]+@enron
- Your regex just with +
instead of *
, as I expect that there must be some letters in each section.
Answer
grep -Evr "[a-z]+.[a-z]+@enron"
Explanation
-E
- Use extended regex. (Allow some characters to be used without escaping them)
-v
- Invert the matches. (Everything that doesn't match the pattern will be shown)
-r
- Search files recursively.
[a-z]+.[a-z]+@enron
- Your regex just with +
instead of *
, as I expect that there must be some letters in each section.
edited May 9 at 14:51
answered May 9 at 14:27
Iskustvo
667118
667118
1
This doesn't work at all. Maybe you were looking forgrep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.
â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
 |Â
show 3 more comments
1
This doesn't work at all. Maybe you were looking forgrep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.
â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
1
1
This doesn't work at all. Maybe you were looking for
grep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.â Jesse_b
May 9 at 14:28
This doesn't work at all. Maybe you were looking for
grep -Evr
? This will still show the body of the emails with the x.y@enron addresses though.â Jesse_b
May 9 at 14:28
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
It still wont work though, please test it.
â Jesse_b
May 9 at 14:37
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
I had minimal test, can you please give me example on which it doesn't work?
â Iskustvo
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
the -v is not my option. Now i notice that the files also contain the message that users wrote
â Andres ZW
May 9 at 14:41
1
1
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
Thank you but that is not helping very much. My current regex catches that correctly. You mentioned messages in the content as well and that's why I asked you for the sample.
â Iskustvo
May 9 at 14:59
 |Â
show 3 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442782%2fgrep-find-all-emails-that-dont-have-the-pattern%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Single quote your search pattern. Not only should this not match the correct emails, it should be throwing the following (or similar) error:
-bash: ![a: event not found
. You are trying to run nonsense commands in a subshell.â Jesse_b
May 9 at 14:22
Your grep will need to be a lot more sophisticated to separate out each email from the various files in order to display only those emails that don't have the pattern, versus every line as you have it now.
â Jeff Schaller
May 9 at 14:25
1
Emails, as in full messages, or just email addresses?
â ilkkachu
May 9 at 14:27
i am trying this now grep -E -r -x [^.]*@[a-z]*.com
â Andres ZW
May 9 at 14:34
how can i rewrite (?![a-z]*.[a-z]*@enron) to correct it?
â Andres ZW
May 9 at 14:37