[pid: 28785|app: 0|req: 2291/4303] 192.168.115.161 () {38 vars in 1198 bytes} [Sun Aug 26 12:43:42 2018] GET /v1/posts/ => generated 62220 bytes in 1744 msecs (HTTP/1.1 200) 9 headers in 380 bytes (1 switches on core 3)我使用'grep‘来搜索日志。
grep '[6-9]{4,} msecs' /var/log/wsgi/wsgi.log请帮我过滤所有响应时间大于6秒的日志。
谢谢
发布于 2018-08-26 22:14:33
不要试图使用regexp进行数字比较,使用能够理解数字的工具,例如awk。如果这还不是你需要的全部:
awk '$24>6000' file例如:
$ cat file
[pid: 28785|app: 0|req: 2291/4303] 192.168.115.161 () {38 vars in 1198 bytes} [Sun Aug 26 12:43:42 2018] GET /v1/posts/ => generated 62220 bytes in 1744 msecs (HTTP/1.1 200) 9 headers in 380 bytes (1 switches on core 3)
[pid: 28785|app: 0|req: 2291/4303] 192.168.115.161 () {38 vars in 1198 bytes} [Sun Aug 26 12:43:42 2018] GET /v1/posts/ => generated 62220 bytes in 5744 msecs (HTTP/1.1 200) 9 headers in 380 bytes (1 switches on core 3)
[pid: 28785|app: 0|req: 2291/4303] 192.168.115.161 () {38 vars in 1198 bytes} [Sun Aug 26 12:43:42 2018] GET /v1/posts/ => generated 62220 bytes in 6744 msecs (HTTP/1.1 200) 9 headers in 380 bytes (1 switches on core 3)
$ awk '$24>6000' file
[pid: 28785|app: 0|req: 2291/4303] 192.168.115.161 () {38 vars in 1198 bytes} [Sun Aug 26 12:43:42 2018] GET /v1/posts/ => generated 62220 bytes in 6744 msecs (HTTP/1.1 200) 9 headers in 380 bytes (1 switches on core 3)然后编辑您的问题,以提供具有简明、可测试的样本输入和预期输出的Minimal, Complete, and Verifiable example。
https://stackoverflow.com/questions/52026416
复制相似问题