9

In all the tools to get colors with less command: -R, Pygments, GNU Source-highlight, vless, ... ccze make me sastified with below command:

ccze -A < /path/to/log/file | less -R

but Shift+g doesn't work as expected:

  • I must press Ctrl+c first
  • follow by Shift+g, but it doesn't go to the end of file

Did I miss something?

2 Answers 2

7
+25

I see similar behavior as you describe when I try this on /var/log/syslog which is 2.1MB in size and around 22500 lines long. Suspecting that ccze was partly to blame for it, I ran:

time ccze -A /var/log/syslog > foo

Which showed that ccze takes around 55 seconds on my 1.2GHz machine to generate the colorized output. I expect this is what makes less hang, less cannot go to the end of the output before ccze has finished generating it, so less seems to hang.

Alternatives to make this work better:

  • Select output with grep, sed etc. and then pipe into ccze.
  • Pre-colorize file and run less on that.
7
  • Is there any tool to pre-colorize the log file? Commented Jul 28, 2012 at 14:21
  • I was thinking along the lines of ccze -A LOG > SOME_FILE. Perhaps executed in a cron job. Commented Jul 28, 2012 at 14:26
  • What do you need it for, does it have to output ANSI sequences? I usually use vim for log viewing, it has good syntax highlighting. Just tested it on a 7 MB log file with no noticable lag. Commented Jul 28, 2012 at 14:52
  • :se ft=sql doesn't make me happy when viewing /var/log/mysqld.log. Commented Jul 28, 2012 at 15:07
  • 1
    Here is an adapted syntax/messages.vim, pretty simple syn match only. Fetch it here, put it into ~/.vim/syntax and run :set ft=mysqllog. Commented Jul 28, 2012 at 22:47
0

Both Meta-> and Meta-< work perfectly fine for me. I'm used to them because they do the same in emacs

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.