Bulk create accounts system 10, and set the password (a random number, and numbers required mixed character (first)

! # / bin / bash 
for i in `seq 1 10` 
do 
        IF the above mentioned id user- $ i> / dev / null; the then 
            the Read -ep" user- $ i user already exists, whether to remove (the y-/ the n-) "SS 
            IF [= SS $ Y]; the then 
                the userdel -rf I $ user- 
            elif [$ = n-SS]; the then 
                Continue 
            the else 
                "input error" 
            Fi 
        the else 
            the useradd user- $ I 
            IF [-eq $ 0?]; the then 
                echo " user- $ i successfully created " 
                passwd =" user`cat / dev / urandom | head -1 | md5sum | head 5` -c " 
                echo" user- $ i: $ passwd "chpasswd 
                echo "user-$i--$passwd" >> aa.txt
            the else 
                echo "$ i user- creation failed."
            - fi - 
        fi 
Done

  

Guess you like

Origin www.cnblogs.com/luyuheng/p/11640448.html