vim users.sh
!/bin/bash
if [ $# -lt 1 ];then
echo "请输入参数add:"
exit 0
fi
if [ $1 == "add" ];then
for I in {1..10}; do
if id user$I &>/dev/null;then
echo "用户 user$I 已存在"
else
useradd user$I
echo user$I | passwd --stdin user$I &> /dev/null
echo "user$I add sucessful"
id user$I
grep user$I /etc/passwd | cut -d : -f1
grep user$I /etc/shadow | cut -d : -f2
fi
done
fi