1 ! # / Bin / bash 2 for i in `seq 1 10 ` 3 do 4 IF the above mentioned id tom- $ i> / dev / null ; the then 5 the Read -ep " tom- $ i already exist, whether to remove - (y / n-) " SS . 6 IF [SS = $ Y]; the then . 7 the userdel -rf tom- $ I . 8 elif [$ SS = n-]; the then . 9 Continue 10 the else . 11 " input error " 12 is Fi 13 is else 14 useradd tom-$i 15 if [ $? -eq 0 ];then 16 echo "tom-$i 创建成功" 17 passwd="user cat /dev/random | head -1 | md5sum | head -c 5" 18 echo "tom-$1:$passwd" chpasswd 19 echo "tom-$i--$passwd" >> user.txt 20 else 21 echo "tom-$i 创建失败" 22 - fi 23 - fi 24 Done