#! /bin/bash if [ $# -lt 1 ]; then echo "usage:admin ARC" exit 7 fi if [ $1 == 'add' ]; then for i in {1..10}; do if id user$i &> /dev/null; then echo "user$i exists" else useradd user$i echo user$i | passwd --stdin user$i &> /dev/null echo "add user$i finished" fi done elif [ $1 == 'del' ]; then for i in {1..10}; do if id user$i &> /dev/null; then userdel -r user$i echo "delete user$i" else echo "No user$i" fi done else echo "Unknown ARG" exit 8 fi
#! /bin/bash if [ $1 == '--add' ]; then for i in `echo $2 | sed 's/,/ /g'`; do if id $i &> /dev/null; then echo "$i exit" else useradd $i echo $i | passwd --stdin $i &> /dev/null echo "add $i finished" fi done elif [ $1 == '--del' ]; then for i in `echo $2 | sed 's/,/ /g'`; do if id $i &> /dev/null ; then userdel -r $i echo "$i deldete" else echo "$i not exit" fi done else echo "Unknown options" fi