标签:ESS com one print .com 记录 文件 $nf sts
[james@zat2 scripts]$ awk -f 2.awk
1 nimei
2 nige
[james@zat2 scripts]$
[james@zat2 scripts]$ cat 2.awk
#/bin/awk
BEGIN{
array[1]="nimei"
array[2]="nige"
for (key in array)
print key,array[key]
}
[james@zat2 scripts]$ for n in 1 2 3 ; do echo $n ; done
1
2
3
[james@zat2 scripts]$ awk ‘BEGIN{array[1]="nimei";array[2]="nige";for(key in array) print key,array[key]}‘
1 nimei
2 nige
[james@zat2 scripts]$ awk ‘BEGIN{array[1]="nimei";array[2]="nige";}END{for(key in array) print key,array[key]}‘ /etc/hosts
1 nimei
2 nige
[james@zat2 scripts]$ awk ‘{S[$1]=$2}END{for(k in S) print k,S[k]}‘ 2.txt
1 nimei
2 nige
[james@zat2 scripts]$ cat 2.txt
1 nimei
2 nige
[james@zat2 scripts]$ awk -F "/" ‘{S[$3]++}END{for(k in S) print k,S[k]}‘ 2.txt
1
baidu.com.cn 3
sohu.com.cn 1
sina.com.cn 2
a=a+1 === a++ ====a+=1
[james@zat2 scripts]$ awk -F"/" ‘{print $3}‘ 2.txt |sort |uniq -c | sort -rn
3 baidu.com.cn
2 sina.com.cn
1 sohu.com.cn
过滤tcp开头 打印最后一列记录个数
awk ‘/^tcp/ {S[$NF]++}END{for(k in S) print k,S[k]}‘ netstat.log
统计访问次数*文件大小 访问次数 文件名
awk ‘{print $7 "\t" $10}‘ access.log | sort | uniq -c|awk ‘{print $1*$3,$1,$2}‘ |sort -rn |head
标签:ESS com one print .com 记录 文件 $nf sts
原文地址:https://www.cnblogs.com/zhanzhan/p/9021079.html