Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 230

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 300

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 301

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 302

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 305

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 308

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 311

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320
awk – 理想社会

Tagawk

用awk统计正在连接的ip

方法一
netstat -antp | awk -F"[ :]+" '/80/{a[$6]}END{for(i in a)print i|"sort -n"}'
方法二
netstat -antp | grep 80 | awk '{print $5}' | cut -d":" -f1 | sort -n | awk -F'.' '!a[$NF]++'
netstat -antp | grep 80 | awk '{print $5}' | cut -d":" -f1 | sort -n | awk -F'.' '!a[$NF]++' | wc -l

《SED单行脚本快速参考》的awk实现

sed和awk都是linux下常用的流编辑器,他们各有各的特色,本文并不是要做什么对比,而是权当好玩,把《SED单行脚本快速参考》这文章,用awk做了一遍~
至于孰好孰坏,那真是很难评论了。一般来说,sed的命令会更短小一些,同时也更难读懂;而awk稍微长点,但是if、while这样的,逻辑性比较强,更加像“程序”。到底喜欢用哪个,就让各位看官自己决定吧!
PS: 貌似这个配色,单行的代码多了以后,拖动的时候会有点眼花的感觉,将就下吧,呵呵。
文本间隔:
——–
# 在每一行后面增加一空行
sed G
awk '{printf("%snn",$0)}'
# 将原来的所有空行删除并在每一行后面增加一空行。
# 这样在输出的文本中每一行后面将有且只有一空行。

Your sidebar area is currently empty. Hurry up and add some widgets.