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?


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.
  • Is there any tool to pre-colorize the log file? – quanta Jul 28 '12 at 14:21
  • I was thinking along the lines of ccze -A LOG > SOME_FILE. Perhaps executed in a cron job. – Thor Jul 28 '12 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. – Thor Jul 28 '12 at 14:52
  • :se ft=sql doesn't make me happy when viewing /var/log/mysqld.log. – quanta Jul 28 '12 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. – Thor Jul 28 '12 at 22:47

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.