批量创建用户,随机密码,并且把用户名与密码写入文件
//批量创建用户stu01--stu10
#echo stu{01..10}|xargs -n1|sed -r 's#(.*)#useradd \1#g'|bash
#echo stu{01..10}|xargs -n1|awk '{print "useradd "$1}'|bash
#echo stu{01..10}|xargs -n1|sed 's#(.*)#userdel -r \1#g' -r|bash
#echo stu{01..10}|xargs -n1|awk '{print "userdel -r " $1}'|bash
//随机生成八位密码
#echo $RANDOM|md5sum|cut -c1-8
#echo `date +%N`|md5sum|cut -c1-8
#openssl rand -base64 7|cut -c 1-8
//免交互给oldboy设置密码
echo $(echo `echo $RANDOM|md5sum|cut -c1-8`|tee -a ok) |passwd --stdin oldboy
//sed拼接
#echo stu{01..3}|xargs -n1|sed -r 's#(.*)#useradd \1;pass=`echo $date +%N|md5sum|cut -c1-8`; echo $pass|passwd --stdin \1;echo \1 $pass >> ok#g'|bash
//awk拼接
#echo stu{01..10}|xargs -n1|awk '{print "useradd "$1";pass=`echo $RANDOM|md5sum|cut -c1-8`;echo $pass|passwd --stdin "$1";echo "$1" $pass >>passwd.txt"}'|bash