我有一个日志文件,其中包含以下内容:
pip install --upgrade --force-reinstall setuptools
有什么方法可以使用Linux命令删除所有出现的2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: --> POST https://foo.com
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Content-Type: application/json; charset=UTF-8
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Content-Length: 893
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: x-foo-id:blah
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Authorization: Bearer ***
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement:
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: {"url_tags":"utm_campaign"}
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: --> END POST (893-byte body)
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: <-- 400 Bad Request https://foo.com (4443ms)
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Vary: Accept-Encoding
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: x-aax_id: 555
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: x-app-usage: {"call_count":0,"total_cputime":0,"total_time":0}
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: WWW-Authenticate: OAuth "invalid_request" "Invalid parameter"
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Content-Type: text/javascript; charset=UTF-8
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: version: v0.122
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Pragma: no-cache
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: x-xxx-aaa: 123475
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Access-Control-Allow-Origin: *
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Cache-Control: no-store
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: x-aa_id: bfi742bfsa
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Expires: Sat, 01 Jan 2000 00:00:00 GMT
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Date: Wed, 03 Apr 2019 22:30:16 GMT
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: Connection: keep-alive
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement:
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: {"error":{"message":"Invalid parameter"}}
2019-04-03 22:30:16,772 [pool-9-thread-1] INFO wire.CampaignManagement: <-- END HTTP (294-byte body)
吗?
注意:我正在远程计算机上工作,因此无法使用VSCode或Sublime编辑这些内容。
答案 0 :(得分:0)
使用perl:
perl -i -pe 's/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}\d+\[pool-\d+-thread-\d+\]\d+(?:INFO|DEBUG)\d+wire\.CampaignManagement://' file
答案 1 :(得分:0)
与@Gilles Quenot相同:sed。
作为部分通用版本(尽管不优雅)的示例,可以代替使用:
filename test pipe "dir /b/s X:\xxxxxx\*.sas7dbat"
如果胎面,日志级别或名称可能发生变化,请进行相应匹配。