这个问题在这里已有答案:
我有一个名为agent.txt
的日志文件,我想通过在nodepad ++中使用正则表达式删除包含collect_host_stats
等字符串的行来过滤它。
怎么做?谢谢!
[2019-04-03 16:01:27.975] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:28.919] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 13, mem: 21, battery: 99.
[2019-04-03 16:01:30.977] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:31.921] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 14, mem: 21, battery: 99.
[2019-04-03 16:01:33.980] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:34.922] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 13, mem: 21, battery: 99.
[2019-04-03 16:01:36.982] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:37.925] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 14, mem: 21, battery: 99.
[2019-04-03 16:01:39.983] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:40.927] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 13, mem: 21, battery: 99.
[2019-04-03 16:01:42.985] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:43.929] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 13, mem: 21, battery: 99.
[2019-04-03 16:01:45.987] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:46.931] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 15, mem: 21, battery: 99.
[2019-04-03 16:01:48.989] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:54.222] [agent] [info] [OpAgent] constructed.
[2019-04-03 16:01:54.469] [agent] [info] [OpHelper] start begin.
[2019-04-03 16:01:54.474] [agent] [debug] [agent_stat] publish start [tcp://127.0.0.1:8013].
[2019-04-03 16:01:54.761] [agent] [debug] [agent_stat] collect_host_stats stat.
[2019-04-03 16:01:54.768] [agent] [info] [agent_cmd] subscribe start [tcp://127.0.0.1:8014:CMD.PC].
[2019-04-03 16:01:54.768] [agent] [info] [OpHelper] start end.
[2019-04-03 16:01:55.781] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 19, mem: 22, battery: 99.
[2019-04-03 16:01:57.798] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:01:58.783] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 63, mem: 22, battery: 99.
[2019-04-03 16:02:00.805] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:01.784] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 45, mem: 22, battery: 99.
[2019-04-03 16:02:03.807] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:04.786] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:06.810] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:07.787] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:09.812] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:10.789] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:12.815] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:13.791] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:15.817] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:16.792] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:18.819] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:19.793] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:21.822] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:22.795] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:24.825] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:25.796] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:02:27.827] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:28.798] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:30.829] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:31.799] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:02:33.831] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:34.800] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 23, mem: 22, battery: 99.
[2019-04-03 16:02:36.834] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:37.801] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:39.837] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:40.803] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:42.839] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:43.804] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:02:45.842] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:46.806] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:48.845] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:49.808] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:51.847] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:52.810] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:02:54.850] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:55.812] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:02:57.852] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:02:58.814] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:00.854] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:01.816] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:03:03.857] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:04.817] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 19, mem: 22, battery: 99.
[2019-04-03 16:03:06.859] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:07.819] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:09.861] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:10.821] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:12.864] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:13.822] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:03:15.866] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:16.823] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:18.869] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:19.824] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:03:21.871] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:22.825] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:24.873] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:25.827] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:03:27.875] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:28.828] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 23, mem: 22, battery: 99.
[2019-04-03 16:03:30.877] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:31.830] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:33.880] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:34.831] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:03:36.882] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:37.834] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:39.884] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:40.836] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:42.886] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:43.838] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:45.889] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:46.840] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 23, mem: 22, battery: 99.
[2019-04-03 16:03:48.892] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:49.842] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:03:51.894] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:52.844] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:03:54.896] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:55.845] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 20, mem: 22, battery: 99.
[2019-04-03 16:03:57.899] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:03:58.847] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 23, mem: 22, battery: 99.
[2019-04-03 16:04:00.901] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:04:01.848] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:04:03.903] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:04:04.850] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 21, mem: 22, battery: 99.
[2019-04-03 16:04:06.905] [agent] [debug] [agent_stat] collect_host_stats loop.
[2019-04-03 16:04:07.852] [agent] [debug] [agent_stat] ip: 192.168.10.103, cpu: 22, mem: 22, battery: 99.
[2019-04-03 16:04:09.907] [agent] [debug] [agent_stat] collect_host_stats loop.
尝试搜索此模式:
^.*\bcollect_host_stats\b.*\R
然后用空字符串替换。请注意,我在collect_host_stats
周围放置了单词边界,以避免将此术语与其他术语的子字符串相匹配。