技术日志

记录分享邓杰律师从事网络技术工作点点滴滴。

位置:首页>资讯动态>技术日志

notepad++替换删除相关代码内容常用技巧汇总

点击复制标题网址

——温馨提示——

已复制到剪贴板,可粘贴到下一处。


时间:2023-09-17   访问量:1116

编者按:一、将含有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(.*)$

未命名-1.jpg

        二、将-字符所在行-后面的内容全部删除。

例子:

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 -]

在查找目标框中输入-.*,选择全部替换。

未命名-1.jpg

        三、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:并选择全部替换。

notepad.png

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

发表评论:

评论记录:

未查询到任何数据!
关于律师
————受人之托,忠人之事————
深圳数据合规律师
邓杰律师

专业

专注执业领域事务

尽责

全力办理委托事项

务实

扎实维护合法权益

邓杰系深耕于数据合规领域复合型资深专业律师,其律师执业证号为14403201810022100。邓杰律师现(曾)任WEB前端开发工程师、WEB服务器维护工程师、计算机信息网络安全员、深圳市人民政府听证员、深圳市政府采购评审专家(法律类)、深圳市某区政府系统公职律师,在网络领域和政府系统从业多年,深刻理解网络前沿技术和行政程序运行规则,十分擅长互联网+平台领域数据合规法律实务,可为政府、企业和个人在数据合规领域提供富有针对性的非诉、诉讼、仲裁、执行等法律风险防控解决方案,能有效维护当事人的各类合法权益。

扫一扫,存名片

深圳数据合规律师名片

律师名片

QQ扫一扫

深圳数据合规律师qq

QQ咨询

电话咨询

邓杰律师电话:13715198118

请输入您的联系电话,座机请加区号

电话咨询

微信扫一扫

深圳数据合规律师微信

微信联系