题解 | #nginx日志分析5-统计爬虫抓取404的次数#
nginx日志分析5-统计爬虫抓取404的次数
http://www.nowcoder.com/practice/3a3573822a854710a259d89066aad695
#! /usr/bin/env bash
########################################################
#
#
########################################################
function solution_1() {
grep 'www.baidu.com' nowcoder.txt | grep ' 404 ' | wc -l
}
########################################################
#
#
########################################################
function solution_2() {
awk '{
if ($0 ~ '/www.baidu.com/' && $9 = 404 ) a++
} END {
print a
}' nowcoder.txt
}
solution_2
查看7道真题和解析
