脚本名称:test4.txt
cd /optmkdir shelllsvi test4.txt
脚本内容如下:
#!/bin/bash[ ! $# -eq 1 ] && echo "Args is error" && exit 5id $1 &>/dev/null && echo "User $1 exist" && exit 2id $1 &>/dev/null || useradd $1id $1 &>/dev/null && echo "$1" | passwd --stdin $1 &>/dev/null && echo "Add User $1 Success." COUNT=`wc -l /etc/passwd | awk '{print $1}'`echo "Total Users is $COUNT"