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

 

上一篇:使用时间戳配合LocalDate.ofEpochDay(days)方法获取的日期不准确的问题!


下一篇:Java中wait()方法为什么要放在同步块中 即lost wake up问题