1、
#!/bin/bash
awk 'BEGIN {
printf "%s,%5s,%4s\n", "IP","AVG","MAX"
}
{
A[$1]++;SNF[$1]+=$NF;
MAXNF[$1]=($NF>MAXNF[$1]?$NF:MAXNF[$1]) //如果MAXNF[$1]小于$NF 那就$NF的值给MAXNF[$1] 否则就是MAXNF[$1]
}END{
for (IP in A) print IP,SNF[IP]/A[IP],MAXNF[IP]
}' a
2、
#!/bin/bash
cat XXX |awk ‘BEGIN{printf “%-18s%5s%5s\n”,”IP”,”Begin”,”End”;
}
{
if (MIN[$2]==”")
{
MIN[$2]=$1;
MAX[$2]=$1;
}
A[$2]++;
MAX[$2]=($1>MAX[$2]?$1:MAX[$2]);
MIN[$2]=($1
}END{for (IP in A) printf “%-18s%-5s%5s\n”,IP,MIN[IP],MAX[IP]}’ |sort -k2n
阅读(952) | 评论(0) | 转发(0) |