假设nginx的日志存储在nowcoder.txt里,内容如下: 192.168.1.20 - - [21Apr2020:14:12:49 +0800] "GET 1index.php HTTP1.1" 301 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.21 - - [21Apr2020:15:00:49 +0800] "GET 2index.php HTTP1.1" 500 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [21Apr2020:21:21:49 +0800] "GET 3index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.23 - - [21Apr2020:22:10:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.24 - - [22Apr2020:15:00:49 +0800] "GET 2index.php HTTP1.1" 200 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.25 - - [22Apr2020:15:26:49 +0800] "GET 3index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.20 - - [23Apr2020:08:05:49 +0800] "GET 2index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (compatible; Baiduspider2.0; +http:www.baidu.comsearchspider.html)" 192.168.1.21 - - [23Apr2020:09:20:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [23Apr2020:10:27:49 +0800] "GET 1index.php HTTP1.1" 200 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [23Apr2020:10:27:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.20 - - [23Apr2020:14:12:49 +0800] "GET 1index.php HTTP1.1" 200 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.21 - - [23Apr2020:15:00:49 +0800] "GET 2index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [23Apr2020:15:00:49 +0800] "GET 3index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (compatible; Baiduspider2.0; +http:www.baidu.comsearchspider.html)" 192.168.1.22 - - [23Apr2020:15:00:49 +0800] "GET 3index.php HTTP1.1" 200 490 "-" "Mozilla5.0 (compatible; Baiduspider2.0; +http:www.baidu.comsearchspider.html)" 192.168.1.24 - - [23Apr2020:20:27:49 +0800] "GET 2index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.25 - - [23Apr2020:20:27:49 +0800] "GET 3index.php HTTP1.1" 200 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.20 - - [23Apr2020:20:27:49 +0800] "GET 1index.php HTTP1.1" 300 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.21 - - [23Apr2020:20:27:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [23Apr2020:20:27:49 +0800] "GET 1index.php HTTP1.1" 500 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.22 - - [23Apr2020:22:10:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 192.168.1.21 - - [23Apr2020:23:59:49 +0800] "GET 1index.php HTTP1.1" 404 490 "-" "Mozilla5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko20100101 Firefox45.0" 现在需要编写shell脚本统计百度爬虫抓取404的次数,你的脚本应该输出 2
输入描述:
1


输出描述:
1
示例1

输入

192.168.1.20 - - [21/Apr/2020:14:12:49 +0800] "GET /1/index.php HTTP/1.1" 301 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.21 - - [21/Apr/2020:15:00:49 +0800] "GET /2/index.php HTTP/1.1" 500 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [21/Apr/2020:21:21:49 +0800] "GET /3/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.23 - - [21/Apr/2020:22:10:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.24 - - [22/Apr/2020:15:00:49 +0800] "GET /2/index.php HTTP/1.1" 200 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.25 - - [22/Apr/2020:15:26:49 +0800] "GET /3/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.20 - - [23/Apr/2020:08:05:49 +0800] "GET /2/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
192.168.1.21 - - [23/Apr/2020:09:20:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [23/Apr/2020:10:27:49 +0800] "GET /1/index.php HTTP/1.1" 200 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [23/Apr/2020:10:27:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.20 - - [23/Apr/2020:14:12:49 +0800] "GET /1/index.php HTTP/1.1" 200 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.21 - - [23/Apr/2020:15:00:49 +0800] "GET /2/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [23/Apr/2020:15:00:49 +0800] "GET /3/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
192.168.1.22 - - [23/Apr/2020:15:00:49 +0800] "GET /3/index.php HTTP/1.1" 200 490 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
192.168.1.24 - - [23/Apr/2020:20:27:49 +0800] "GET /2/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.25 - - [23/Apr/2020:20:27:49 +0800] "GET /3/index.php HTTP/1.1" 200 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.20 - - [23/Apr/2020:20:27:49 +0800] "GET /1/index.php HTTP/1.1" 300 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.21 - - [23/Apr/2020:20:27:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [23/Apr/2020:20:27:49 +0800] "GET /1/index.php HTTP/1.1" 500 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.22 - - [23/Apr/2020:22:10:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
192.168.1.21 - - [23/Apr/2020:23:59:49 +0800] "GET /1/index.php HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"

输出

2
加载中...