Sunday, April 3, 2016

grepping in color with less

Yes, I like to use grep, but I like to pipe it to less, AND I like the color highlighting.

How do I get all of these to work together?

firstly, grep with --color=always

then pipe it to less with the -R switch


then you get the lovely colors:


so for instance:

less traceout2.txt | grep -n -A 3 -B 2 'ONI A,$01' --color=always | less -R

gives me:



No comments:

Post a Comment