#!/usr/bin/bash read -p "please input number:" num if [[ ! "$num" =~ ^[0-9]+$ ]];then echo "error number" exit fi read -p "please input prefix:" prefix if [ -z $prefix ];then echo "error prefix" fi for i in `seq $num` do user=$prefix$i usesradd $user echo "123" |passwd --sdtin $user &>/dev/null if [ $? -eq 0 ]; then echo "$user is created" fi done
标签:number,创建,练习,用户,echo,prefix,num,user,fi From: https://www.cnblogs.com/smatter/p/16936672.html