Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted
+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.
share|improve this answer
    
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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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