首页 > 其他 > 详细

uniq -c 去掉重复行

时间:2021-09-21 00:34:21      阅读:4      评论:0      收藏:0      [点我收藏+]

[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 去掉重复行

原文:https://www.cnblogs.com/vzhangxk/p/15303246.html

(0)
(0)
   
举报
评论 一句话评论(0
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!