脚本名称:test4.txt
cd /opt mkdir shell ls vi test4.txt
脚本内容如下:
#!/bin/bash [ ! $# -eq 1 ] && echo "Args is error" && exit 5 id $1 &>/dev/null && echo "User $1 exist" && exit 2 id $1 &>/dev/null || useradd $1 id $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"
转载于:https://blog.51cto.com/suyanzhu/1943407