0

I have a file which contains a list of email addresses. I would like to send out emails to this list via a bash command. If possible, have the command check for duplicates and not send the email to a duplicate email.

Sample File Input:

  [email protected]
  [email protected]
  [email protected]
  [email protected]

So in this example [email protected] should not receive a duplicate email. Does anyone have any Bash commands to point me in the right direction?

2 Answers 2

3

Try doing this with your file :

mail -s subject "$(sed '/^$/d;s/ *//g' file.txt | sort -u | paste -sd ",")" <<EOF
message here
EOF
Sign up to request clarification or add additional context in comments.

Comments

0
mail -s "Subject" $(sort -u recipients-file) <<<"msg"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.