如何在Linux中查看日志文件并在查看时应用自定义过滤器? [英] How can I view log files in Linux and apply custom filters while viewing?
问题描述
cat logfile.txt | grep -vIgnoreThis \ | IgnoreThat|减去
但是很麻烦 - 每次我想添加另一个过滤器时,我需要退出 less
并编辑命令行。有些过滤器比较复杂,可能是多行的。
我想通过日志读取过滤器,保存这些过滤器的地方。
有没有一个工具可以为我做这个?我不能安装新的软件,所以希望它已经被安装 - 例如,更少,vi,Python或Perl lib中的某些东西等。
更改生成日志生成更少的代码不是一个选项。
试试 multitail 工具 - 让您一次查看多重日志,我敢肯定它可以让您以交互方式应用正则表达式过滤器。I need to read through some gigantic log files on a Linux system. There's a lot of clutter in the logs. At the moment I'm doing something like this:
cat logfile.txt | grep -v "IgnoreThis\|IgnoreThat" | less
But it's cumbersome -- every time I want to add another filter, I need to quit less
and edit the command line. Some of the filters are relatively complicated and may be multi-line.
I'd like some way to apply filters as I am reading through the log, and a way to save these filters somewhere.
Is there a tool that can do this for me? I can't install new software so hopefully it's something that would already be installed -- e.g., less, vi, something in a Python or Perl lib, etc.
Changing the code that generates the log to generate less is not an option.
Try the multitail tool - as well as letting you view multile logs at once, I'm pretty sure it lets you apply regex filters interactively.
这篇关于如何在Linux中查看日志文件并在查看时应用自定义过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!