uniq -c 去掉重复行

[root@aa ~]# netstat -nat |awk -F ‘ ‘ ‘{print $6}‘
established
Foreign
LISTEN
LISTEN
LISTEN
LISTEN
TIME_WAIT
TIME_WAIT
ESTABLISHED
ESTABLISHED
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
TIME_WAIT
ESTABLISHED
ESTABLISHED
TIME_WAIT

[root@aa ~]# netstat -nat |awk -F ‘ ‘ ‘{print $6}‘|uniq -c
1 established)
1 Foreign
9 LISTEN
2 TIME_WAIT
2 ESTABLISHED
15 LISTEN
21 ESTABLISHED
1 TIME_WAIT
18 ESTABLISHED
1 TIME_WAIT
5 ESTABLISHED

sort  -rn  倒序排列

[root@aa ~]# netstat -nat |awk -F ‘ ‘ ‘{print $6}‘|uniq -c|sort -rn
32 ESTABLISHED
15 LISTEN
9 LISTEN
6 ESTABLISHED
6 ESTABLISHED
2 TIME_WAIT
2 ESTABLISHED
1 TIME_WAIT
1 TIME_WAIT
1 Foreign
1 established

 

uniq -c 去掉重复行

上一篇:iOS中xib文件维护使用小结


下一篇:测试人员应该高大上?!