read -p "请输入您创建的用户名:" user
[ -z $user ] && exit
[ ! -z echo $user | awk ‘{print $2}‘
] && exit
[ ! -z echo $user | sed ‘s#[0-9]##g‘ | sed ‘s#[a-Z]##g‘
] && exit
useradd $user
echo "$PASS1" | passwd --stdin $user > /dev/null
echo -e "$PASS1\t$user" >> mail.txt ####### 管理员备份
read -p "请输入您的邮箱帐号:" mail
echo "用户:$user 密码:$PASS1" | mail -s "新建用户$user的密码" -r admin $mail
#######新手第一次写 多多指教
原文地址:http://blog.51cto.com/13740508/2114778