056-建立任意用户组并在任意用户组内建立用户

看到这个需求时,第一时间想到的2个关键字:用户组,用户bash

须要解决的问题code

1.判断输入用户是否为空input

2.两数之间怎么取出中间的数值,用什么方式?cat ?seq? it

#! /bin/bash

##add a new user group, and let all of new user join in.
##written by zhdya_20171011

read -p "pls input a user's group name, like msxf:" g
read -p "pls input a number which from XX and end of XX, like 01 05, it will create msfinance01 ... msfinance05:" n m

if [ -z $g ] && [ -z $n ] && [ -z $m ]
then
        echo "pls it must input the PARA."
        exit
fi

groupadd $g

echo "already created the usergroup $g"

for i in `seq $n $m`
do
        useradd msfinance$i -g $g
done

echo "already created the user you needs."

该脚本不是我写的哈, 看完以后,是否是明白了怎么操做呢? 脚本

相关文章
相关标签/搜索