awk 数组实例2 统计tcp 监听状态;统计web日志文件访问里存储文件的大小

[root@localhost ~]# netstat -an|awk '/^tcp/ {print $NF}'|sort|uniq -c | sort -rn                                 

     21 ESTABLISHED

     10 LISTEN

      3 TIME_WAIT

[root@localhost ~]# netstat -an|awk '/^tcp/''{array[$NF]++}END{for(key in array) print array[key],key}'|sort -rn

21 ESTABLISHED

10 LISTEN

3 TIME_WAIT

[root@localhost ~]#

[root@localhost logs]# awk '{num[$7]++;size[$7]+=$10}END{for(k in num) {print size[k],num[k],k}}' access_log|sort -rn -k1|head

1495294882 3 /downloadmovie.php?mid=58

259994994 4 /downloadmovie.php?mid=67

60042550 589 /kaoshi/app/core/styles/js/ckeditor/ckeditor.js

38838665 521 /kaoshi/files/attach/images/content/20160608/14653543731489.png

35231010 351 /kaoshi/index.php?exam-app-exam-paper

34943680 180 /js/jquery.ui.js

32414264 2 /downloadmovie.php?mid=65

26908690 521 /kaoshi/files/attach/images/content/20160608/14653543516495.png

25308222 587 /kaoshi/app/core/styles/js/jquery-ui.js

22200480 186 /js/jquery.js

[root@localhost logs]#

你可能感兴趣的:(awk 数组实例2 统计tcp 监听状态;统计web日志文件访问里存储文件的大小)