Shell script Instance-Bulk Add user name password

Source: Internet
Author: User

#!/bin/bashread-t 30-p "input name:" Nameread-t 30-p "input number:" num #输入要批量添加的用户数量并将变量赋给numread-t 30-p "input PA ssWOrd: "passif[-N" $name "-a-n" $num "-a-n" $pass "] #判断都不为空theny =$ (echo $num | Sed ' s/^[0-9]//g ') #如果 $num contains 0-9, then the SED is replaced by empty and assigned to Y if [-Z ' $y "] #判断y是否为空, (that is, whether NUM is a number, NULL is a number, or not a number) then for ((i=1;i< $num; i=i+1)) do useradd $name $i &>/dev/null echo $pass | passwd--stdin "$name $i" &>/dev/null #将 $pass pass value to passwd command done else echo "the number was only for numbers!" Fielse Ech O "Your input is invalid!" Fi


Shell Script Instance-Bulk Add user name password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.