[root@mail2 ~]# cat first_mail.sh
#!/bin/bash
#20110523#######
#diff -u /etc/passwd.keep /etc/passwd |grep ^+ |grep -v ^++ |awk -F: '{print $1}'|sed 's/+//' > /etc/userlist.$$
#cat /etc/userlist.$$ |awk '{print "email="$0"@thunderst.com"}' > /etc/sending.$$
#for foo in `cat /etc/sending.$$`
# do
# eval $foo
#sending mail
mail -s "Welcome to ........." tian.zhiying.com << EOF
欢迎新同学!
【全体】
…
【开发】
【测试】
【其他】
EOF
# done
#remove the difference file
# rm -f /etc/userlist.$$
#remove the sending list file
# rm -f /etc/sending.$$
#backup the latest passwd file
# cp -f /etc/passwd /etc/passwd.keep
#!/bin/bash
#20110523#######
#diff -u /etc/passwd.keep /etc/passwd |grep ^+ |grep -v ^++ |awk -F: '{print $1}'|sed 's/+//' > /etc/userlist.$$
#cat /etc/userlist.$$ |awk '{print "email="$0"@thunderst.com"}' > /etc/sending.$$
#for foo in `cat /etc/sending.$$`
# do
# eval $foo
#sending mail
mail -s "Welcome to ........." tian.zhiying.com << EOF
欢迎新同学!
【全体】
…
【开发】
【测试】
【其他】
EOF
# done
#remove the difference file
# rm -f /etc/userlist.$$
#remove the sending list file
# rm -f /etc/sending.$$
#backup the latest passwd file
# cp -f /etc/passwd /etc/passwd.keep
转载于:https://blog.51cto.com/iitnet/579350