Linux下批量添加100個賬號的腳本

Linux下批量添加賬號的小腳本
這個腳本可以批量添加相同前綴的用戶,如果有朋友有更好的的分享下呵呵。。
#!/bin/bash
read -p "Please Input a umber of (1-99):" Num
 until [ $Num -lt 100 ]
 do
echo "User's number must lesser than 100"
read -p "Input a umber of (1-99):" Num
 done
read -p "username prefix is:" prefix
read -p "Expire time is(YYY-MM-DD):" ETIME
read -p "Initial password is:" password
i=1
while [ $i -le $Num ]
do
 if [ $i -lt 10 ]
then
 US=${prefix}0$i
else
 US=${prefix}$i
 fi
useradd -e $ETIME $US
echo $password | passwd --stdin $US &>/dev/null
echo user $US is add Successfull
i=`expr $i + 1`
done
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章