#!/bin/bash # Count=0 for UserName in $@; do if id $UserName &> /dev/null; then echo "$UserName exists." else useradd $UserName echo "Add $UserName successfully." Count=$[$Count+1] fi done echo "Add $Count new users."
原文地址:http://traumlou.blog.51cto.com/8561535/1411910