Getting colored results when using a pipe from grep to less
Problem
I use the --colour option of grep a lot, but I often use less as well. How can I pipe grep results to less and still preserve the coloring. (Or is that possible?) EDIT: I'm looking for a direct solution or anything equivalent to this.
Error Output
grep "search-string" -R * --colour | less
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: Getting colored results when using a pipe from grep to less
When you simply run it implies which detects whether the output is a terminal and if so enables colors. However, when it detects a pipe it disables coloring. The following command: Will always enable coloring and override the automatic detection, and you will get the color highlighting in . EDIT: Although using just works for me, perhaps older version require the flag to handle colors, as therefromhere suggested.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix