Reputation: 196
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?
Upvotes: 0
Views: 456
Reputation: 184955
Try doing this with your file :
mail -s subject "$(sed '/^$/d;s/ *//g' file.txt | sort -u | paste -sd ",")" <<EOF
message here
EOF
Upvotes: 3