I'd like to view logfiles with colored output, scrollable and searchable. How do I do that?
less /var/log/syslog | ccze | grep error, but it is not scrollable.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
That's because you're doing it the wrong way around. It's
less that is scrollable so that needs to be the last command in the pipeline:
grep error /var/log/syslog | ccze -A | less -R
The options used are:
If one wants to enable raw ANSI color sequences instead of using curses, this option does just that.
ccze use ANSI color codes instead of curses. While
less can deal with ANSI escapes with the
-R option (see below), curses are more of a problem. Using the
-A option of
ccze neatly sidesteps that issue.
-R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the form:
ESC [ ... m
where the "..." is zero or more color specification characters For the purpose of keeping track of screen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make less think that characters other than "m" can end ANSI color escape sequences by setting the environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you can make less think that characters other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.