标签:截取日志
leco@leco:~/PycharmProjects/cmz/练习/7并发编程/多线程$ cat web.log192.168.5.109 - - [01/Apr/1027:21:26:21 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:28:22 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:31:36 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:42:14 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:45:22 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:46:32 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:46:54 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:47:03 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:48:31 +0800] "GET / HTTP/1.1" 200 26 192.168.5.109 - - [01/Apr/1027:21:50:08 +0800] "GET / HTTP/1.1" 200 26 192.168.5.109 - - [01/Apr/1027:21:51:21 +0800] "GET / HTTP/1.1" 200 26 192.168.5.109 - - [01/Apr/1027:21:52:48 +0800] "GET / HTTP/1.1" 200 26
sed方式去截取
leco@leco:~/PycharmProjects/cmz/练习/7并发编程/多线程$ sed -n '/21:31:36/,/21:50:08/p' web.log
192.168.5.109 - - [01/Apr/1027:21:31:36 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:42:14 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:45:22 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:46:32 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:46:54 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:47:03 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027:21:48:31 +0800] "GET / HTTP/1.1" 200 26 192.168.5.109 - - [01/Apr/1027:21:50:08 +0800] "GET / HTTP/1.1" 200 26
awk方式去截取
leco@leco:~/PycharmProjects/cmz/练习/7并发编程/多线程$ awk -F':' '$2 = 21 && $3 >= 30 && $3 <= 50' web.log
192.168.5.109 - - [01/Apr/1027 1 31 36 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 42 14 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 45 22 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 46 32 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 46 54 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 47 03 +0800] "GET / HTTP/1.1" 502 172 192.168.5.109 - - [01/Apr/1027 1 48 31 +0800] "GET / HTTP/1.1" 200 26
标签:截取日志
原文地址:http://blog.51cto.com/caimengzhi/2093015