Linux-Shell-awk&指定列去重

zgrep -a PlayerEnterInfo Audit_2016-08-02.tgz|awk -F, '{ar[$7]=$0}; END{for (i in ar) print ar[i];}' #$7为指定的列数, ar[]是awk中的队列

#!/bin/bash
# coding=utf-8
# auth Lee at 20160120

Date=`date +%F -d '-1 days'`
cd /home/maintain/monitor/TserverHum/;
##############################total######################################
for i in `seq 1 8`;do
        echo Server-$i;
                for j in `cat ~/ipinfo/ipinfo|grep -i Server-$i |awk '{print $1}'`;do
                        ssh $j "cd /home/Log/;zgrep -a  PlayerEnterInfo Audit_$Date.tgz"|awk -F, '{ar[$2]=$0}; END{for (h in ar) print ar[h]}';
                done|wc -l
        done >server-num.txt
##############################detail####################################
for i in `cat ~/ipinfo/allgaserver |grep -i ts|grep -v ^#|awk '{print $1}'`;do
        echo $(cat ~/ipinfo/allgaserver|grep -w $i|awk '{print $2}')-------------------------
        ssh $i "cd /home/Log/;zgrep -a  PlayerEnterInfo Audit_$Date.tgz"|awk -F, '{ar[$2]=$0}; END{for (h in ar) print ar[h]}'|wc -l;
        done >> server-num.txt
echo "serverHumcount"|mutt -a server-num.txt -s "【example】 人数分布 " [email protected]

你可能感兴趣的:(Bash_Shell相关,Linux系统管理手记)