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 logf
Based on ghostdog74's answer and the less
manpage, I came up with this:
~/.bashrc
:export LESSOPEN='|~/less-filter.sh %s'
export LESS=-R # to allow ANSI colors
~/less-filter.sh
:#!/bin/sh
case "$1" in
*logfile*.log*) ~/less-filter.sed < $1
;;
esac
~/less-filter.sed
:/deleteLinesLikeThis/d # to filter out lines
s/this/that/ # to change text on lines (useful to colorize using ANSI escapes)
Then:
less logfileFooBar.log.1
-- applies the filter applies automatically.cat logfileFooBar.log.1 | less
-- to see the log without filteringThis is adequate for now but I would still like to be able to edit the filters on the fly.