Grep: find all emails that don't have the pattern

The name of the pictureThe name of the pictureThe name of the pictureClash 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)






share|improve this question





















  • 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














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)






share|improve this question





















  • 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












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)






share|improve this question













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)








share|improve this question












share|improve this question




share|improve this question








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
















  • 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










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.






share|improve this answer



















  • 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











  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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.






share|improve this answer



















  • 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











  • 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














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.






share|improve this answer



















  • 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











  • 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












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.






share|improve this answer















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.







share|improve this answer















share|improve this answer



share|improve this answer








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 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










  • 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




    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










  • 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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay