admin 管理员组

文章数量: 887021


2024年2月7日发(作者:ellipsis)

#!/bin/bash[ "$USER" != "root" ] &&{ echo -e "033[31mError:This script is run as root!!033[0m" exit 0}[ -z "$1" ]&&{ echo -e "033[31mError:Please input userfile following script033[0m" exit 0}[ -e "$1" ]||{ echo -e "033[31mError:$1 is not exist033[0m" exit 0}for USERNAME in `cat $1`do useradd $USERNAME &> /dev/null &&{ echo -e "033[32m$USERNAME is created033[0m" }||{ echo -e "033[31m$USERNAME is exist!!033[0m"}done

#!/bin/bashMax_Line=`awk 'BEGIN{N=0}{N++}END{print N}' $1`for NUM in `seq 1 $Max_Line`do USERNAME=`sed -n ${NUM}p $1` PASSWORD=`sed -n ${NUM}p $2` useradd $USERNAME &>/dev/null &&{ echo $PASSWORD |passwd --stdin $USERNAME &>/dev/null echo $USERNAME is create}||{ echo $USERNAME is exist}done

验证*和@区别$* 脚本后跟的所有字符串,模式为"1 2 3"&@ 脚本后跟的所有字符串,模式为"1" "2" "3"

#####脚本中的函数#########

########使脚本循环:#############例题:


本文标签: 脚本 验证 模式 区别 字符串