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
标签:aa,ESTABLISHED,重复,LISTEN,TIME,去掉,uniq,WAIT 来源: https://www.cnblogs.com/vzhangxk/p/15303246.html