[root@python ~]# cat testcount.txt
a 1.1.1.1b 2.2.2.2c 3.3.3.3a 1.1.1.1d 4.4.4.4e 5.5.5.5f 6.6.6.61.去重:
awk '!a[$1]++ {print}' testcount.txt
a 1.1.1.1
b 2.2.2.2c 3.3.3.3d 4.4.4.4e 5.5.5.5f 6.6.6.62.统计第二列
awk '{a[$1]++} END{for (i in a) print a[i],i}' testcount.txt
2 a
1 b1 c1 d1 e1 f3.统计日志中访问大于100次的IP
[root@python ~]# awk '{a[$1]++}END{for (i in a) {if (a[i] >1) print a[i],i}}' testcount.txt
2 a过滤邮箱地址
[root@python ~]# egrep '[a-z0-9]{3,}\@[1-9a-z]{4,}\.[1-9a-z]{2,}' oldboy.txt
linuxdxw@onecloud.cn[root@python ~]# egrep '[a-z0-9]{3,}\@[1-9a-z]{4,}\.[1-9a-z]{2,}' oldboy.txt过滤ip地址
[root@python ~]# egrep '[0-9]{1,3}(\.[0-9]){3}' oldboy.txt
inet addr:10.0.0.8 Bcast:10.0.0.255 Mask:255.255.255.0inet addr:10.0.0.8 Bcast:10.0.0.255 Mask:255.255.255.0过滤mac地址
[root@python ~]# egrep '[0-9a-z]{2}(\:[0-9a-z]{2}){5}' oldboy.txt
link/ether 02:00:47:76:00:6c brd ff:ff:ff:ff:ff:ff