记录分享邓杰律师从事网络技术工作点点滴滴。
编者按:一、将含有HTTP内容的所在行删除,代码如下:^(.*)HTTP(.*)$二、
一、将含有HTTP内容的所在行删除。
例子:
103.83.144.161 - [-] [2023-09-09T20:30:57+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
103.83.144.161 - [-] [2023-09-09T20:30:57+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
103.83.144.161 - [-] [2023-09-09T20:30:59+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
103.83.144.161 - [-] [2023-09-09T20:31:01+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
103.83.144.161 - [-] [2023-09-09T20:31:06+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
103.83.144.161 - [-] [2023-09-09T20:31:12+08:00] "[-] [-] POST /cgi-bin/luci/;stok=/locale?form=country HTTP/1.1" 400 [-] [- 150 0.000 -]
删除替换代码如下:
^(.*)HTTP(.*)$

二、将-字符所在行-后面的内容全部删除。
例子:
39.100.84.190 - [-] [2023-09-09T00:16:52+08:00] "[-] [-] test" 400 [-] [- 150 1.576 -]
39.100.84.190 - [-] [2023-09-09T00:17:00+08:00] "[-] [-] " 400 [-] [- 0 5.007 -]
39.100.84.190 - [-] [2023-09-09T00:17:04+08:00] "[-] [-] " 400 [-] [- 150 2.121 -]
39.100.84.190 - [-] [2023-09-09T00:17:12+08:00] "[-] [-] test" 400 [-] [- 150 3.801 -]
在查找目标框中输入-.*,选择全部替换。

三、将client: 字符所在行前面的内容全部删除。
例子:
2023/10/02 14:15:10 [error] 4524#4760: *4434 "c:/host/host001/acom/clo/index.html" is not found (3: The system cannot find the path specified), client: 101.36.229.24, server: a.com, request: "GET /clo/ HTTP/1.1", host: "www.a.com"
2023/10/02 14:15:10 [error] 4524#4760: *4436 "c:/host/host001/acom/contract/index.html" is not found (3: The system cannot find the path specified), client: 101.36.229.24, server: a.com, request: "GET /contract/ HTTP/1.1", host: "www.a.com"
2023/10/02 14:16:31 [error] 4524#4760: *4444 CreateFile() "c:/host/host002/bcn/robots.txt" failed (2: The system cannot find the file specified), client: 100.21.24.205, server: b.cn, request: "GET /robots.txt HTTP/1.1", host: "www.b.cn"
2023/10/02 14:16:31 [error] 4524#4760: *4444 CreateFile() "c:/host/host002/bcn/404.html" failed (2: The system cannot find the file specified), client: 100.21.24.205, server: b.cn, request: "GET /robots.txt HTTP/1.1", host: "www.b.cn"
2023/10/02 14:17:08 [error] 4524#4760: *4483 CreateFile() "c:/host/host002/bcn/404.html" failed (2: The system cannot find the file specified), client: 52.25.208.208, server: b.cn, request: "GET /robots.txt HTTP/1.1", host: "www.b.cn"
2023/10/02 14:19:34 [error] 4524#4760: *4597 "c:/host/host001/acom/guarantee/index.html" is not found (3: The system cannot find the path specified), client: 101.36.229.24, server: a.com, request: "GET /guarantee/ HTTP/1.1", host: "www.a.com"
在查找目标框中输入^(.*)client:并选择全部替换。

上述技巧在分析nginx日志并从中提取相关ip地址时可能需要用到。

专注执业领域事务
全力办理委托事项
扎实维护合法权益

邓杰律师电话:13715198118
请输入您的联系电话,座机请加区号
