标签:shell sed pre cas ase name ash add more
#!/bin/bash adduser(){ echo "Copy authz File authz to `date "+%Y%m%d%s"`"&&cp authz authz`date "+%Y%m%d%s"` # more authz | grep ^[A-Z] | grep $DP | sed ‘s/$/&,‘$USER‘/g‘ > authz.new sed -i ‘/^‘$DP‘/s/$/,‘$USER‘/‘ authz } process(){ if [ "$DP" != "" ] then for i in `more authz | grep "$DP =" | grep -v @ | awk ‘{print $3}‘ | tr "," "\n"` do more passwd | grep $i > /dev/null 2>&1 if [ $? = 1 ]; then echo "Copy passwd File to passwd`date "+%Y%m%d%s"`"&&cp passwd passwd`date "+%Y%m%d%s"` sed -i ‘/‘$DP‘/a\‘$i‘ = ‘$i‘@emoney‘ passwd more passwd | grep $i > /dev/null 2>&1 if [ $? = 0 ]; then echo "User $i Add Succes" else echo "User $i Add Flase" fi fi done else echo "Department ID not set" fi } read -p "Please Input New UserName:" USER read -p "Please Input Department ID:" DP case $DP in Market_SEM) adduser sleep 1 process ;; Market_UE) adduser sleep 1 process ;; JSB_JG) adduser sleep 1 process ;; JSB_OP) adduser sleep 1 process ;; Market_PD) adduser sleep 1 process ;; Market_mk2) adduser sleep 1 process ;; Market_PR) adduser sleep 1 process ;; *) if [ "$DP" = "" ] then echo "Department ID not set" else echo -e "Department Mistake\n#####Detail List######\nMarket_SEM\nMarket_UE\nJSB_JG\nJSB_OP\nMarket_PD\nMar ket_mk2\nMarket_PR\n#####Detail List######" fi ;; esac
标签:shell sed pre cas ase name ash add more
原文地址:http://www.cnblogs.com/beckham-7/p/6517986.html