Linux Shell编程
用shell,统计如下日志文件中10月19日中午12:00到14:00间连接成功的次数。
……
Oct 18 13:02:35.049 2005@Connect 192.21.134.10 success.
……
Oct 19 10:58:35.018 2005@Connect 119.53.21.88 success.
……
Oct 19 12:58:35.018 2005@Connect 60.21.134.10 failed.
Oct 19 13:40:37.627 2005@Connect 171.22.15.4 success.
Oct 19 13:43:47.017 2005@Connect 162.55.12.76 failed.
……
Oct 19 14:02:35.049 2005@Connect 192.21.45.110 success.
Oct 19 15:27:24.049 2005@Connect 221.23.14.130 failed.
……
Oct 20 15:21:54.113 2005@Connect 143.43.15.33 success.
……
大家帮帮忙啊!
------解决方案--------------------
$ awk 'BEGIN{FS="[: +\t]"}{if($3>=12&&$3<=13&&$NF~/success/)num++}END{print "Total success connection during 12~14: "num}' log.txt
Total success connection during 12~14: 2