0

I have been given a list of disposable emails and other emails that my company does not want in our mailing list and asked to remove them. I know grep -v or awk !/xxx/' but this is against a list of 1000 email domains they do not want. I could use a bash script but they are only being sorted one at a time which still leave manual sorting. Any ideas are welcone please

closed as unclear what you're asking by Jeff Schaller, Jesse_b, user34720, Anthony Geoghegan, Kusalananda Mar 22 at 20:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You haven't really explained what you are trying to do. What do you want to grep? – Jesse_b Mar 21 at 20:01
  • 3
    So, you have a mailing list file "A". You also have a thousand-plus lines list of domains and email addresses "B" to remove from the mailing list file. You want a fairly rapid automated method to remove B from A. Is that correct? Please click edit and clarify your question. – K7AAY Mar 21 at 20:08
2

If I understand you correctly you have a file that is a mailing list.

$ cat mail_list
email1@domain1.com
email2@domain2.com
email3@domain3.com
email4@domain4.com
email5@domain5.com

You have a file that is a black list.

$ cat blacklist
email2@domain2.com
email4@domain4.com

You want to make a new mailing list file with the email addresses in the black list removed?

Using the blacklist file with grep:

-f file, --file=file

Read one or more newline separated patterns from file. Empty pattern lines match every input line. Newlines are not considered part of a pattern. If file is empty, nothing is matched.

$ grep -vxFf blacklist mail_list
email1@domain1.com
email3@domain3.com
email5@domain5.com

To make a new mailing list you would redirect this into the file like:

$ grep -vxFf blacklist mail_list > new_mail_list

Which you could then use to overwrite the old mail list

$ mv new_mail_list mail_list

Not the answer you're looking for? Browse other questions tagged or ask your own question.