#!/bin/bash #set -x host=`hostname` ip=`ifconfig $(ip a|grep eth|head -n1|awk -F: '{print $2}') |grep 'inet addr:'|awk -F: '{print $2}'|awk '{print $1}'` function pan(){ for i in $@ do if [ $i == 'cditv' ];then echo 0 && exit fi done } > /tmp/tttt.txt > /tmp/temp > /tmp/temp0 > /tmp/temp1 y=`cat /etc/passwd|grep '/bin/bash'|grep -vE 'zabbix|root|nginx|fpm|sperm'|awk -F: '{print $1}'` x=`pan $y` if [ -z $x ];then echo -ne $host-$ip >> /tmp/temp for i in $y do k=`groups $i|awk '{print $4}'` if [ -z $k ];then echo $i >> /tmp/temp1 elif [ $k != 'cditv' ];then echo $i >> /tmp/temp1 elif [ $k == 'cditv' ];then echo $i >> /tmp/temp0 fi done elif [ $x == 0 ];then echo -ne $host-$ip >> /tmp/temp for i in $y do k=`groups $i|awk '{print $4}'` if [ $i == 'cditv' ];then echo $i >> /tmp/temp0 else if [ -z $k ];then echo $i >> /tmp/temp1 elif [ $k != 'cditv' ];then echo $i >> /tmp/temp1 elif [ $k == 'cditv' ];then echo $i >> /tmp/temp0 fi fi done fi paste /tmp/temp /tmp/temp0 /tmp/temp1 > /tmp/tttt.txt #合成3列 rm -rf /tmp/temp /tmp/temp0 /tmp/temp1 cat /tmp/tttt.txt echo -ne " "