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.
cat FILE | ...
. Better would begrep args < FILE | ...
or justgrep args FILE | ...
– Venutigrep -v "OneFilter" < FILE | grep -v "AnotherUglyLongFilter" | grep -v "etc." | less
... I guess just because it buries the filename a bit more. – Reevacat FILE | grep .. | awk ... | sort
is more clear. The problem is not style, it is performance, as this way one more process is created and more inter-process communication happens. This is usually no problem for interactive commands, but in scripts the more ugly form should be used. – Martinez