I would like to change the way I display a big (~6000 lines) log file using wim, less or whatever, in order to simplify the problem checking. I'd like to highlight some line of the log based on a patter (i.e. error, warning, info...) and/or hide some others. Which tools could I use? Do I just need a shell script? It's important that after the process, I can read the output using less, vim, ... to perform search operations!Edit: a little piece of the log:2016/10/25 12:19:24.403355 INFO <ServiceManager.cpp#2614 TID#3> Security object has NOT been parsed2016/10/25 12:19:24.403369 INFO <ServiceManager.cpp#1263 TID#3> Service object sequence started2016/10/25 12:19:24.403372 DBG <ServiceManager.cpp#1276 TID#3> preinvoke succeeded
Shell - Customize the color of each line of a log file based on a pattern
text processing;colors;syntax highlighting
I would recommend a shell script, based on awk like Valentin B. solution:$ cat colorizeawk 'function color(c,s) {        printf(\033[%dm%s\033[0m\n,30+c,s)}/error/ {color(1,$0);next}/success/ {color(2,$0);next}/warning/ {color(3,$0);next}/INFO/ {color(4,$0);next}/DBG/ {color(5,$0);next}{print}' $1In order to be able to interactively view the colorized output, I would use less in raw mode, e.g.:colorize mylog.txt | less -R