上代码:
#!/bin/bash #---------------------------------------------------------------- # Powered by blog.linuxbaodian.com # # File Name:night_00_tar_etc.sh # Description:backup /etc to /backup/{IP} # author:Guilin Chen # Date:2018-08-12 # # Create identity:New # Modifying identities:v1.0 # Modify Description: #---------------------Http://blog.linuxbaodian.com------------------------ UPath="/server/scripts/" UserFile=$UPath"userlist3.txt" Nulls="/dev/null" UserName=(`awk -F":" '{print $1}' $UserFile`) Password=(`awk -F":" '{print $2}' $UserFile`) UserCount=${#UserName[*]} DoneUser=0 Msg=""
现在开始添加
处理完成,输出日志或屏幕提示:
Msg=$(date +%F" "%T)" 执行成功,本次提交用户数:"$UserCount" 成功添加用户数:"$DoneUser if [ $? -eq 0 ];then echo $Msg >>$UPath"Useradd.log" fi echo $Msg
用户列表文件userlist3.txt
[root@oldboyedu scripts]# cat userlist3.txt xingys:03075656 liuw:03075657 huxp:03075658 liux:03075659 fangdc:03075660 caoy:03075661 zhangxm:03075662 wangy:03075663 mam:03075664 jiyn:03075665
至此添加完成!