I'm using grep from the command line via cygwin. I'm wondering if there's any way to get it to highlight the part of each line that matches the regex. The closest thing I'm seeing is the -o option, but that only outputs the matching area, and I'd like to see the entire line.
Take a look at the --color (or --colour) option, e.g.
grep --color POST access_log
By default, this uses the "auto" mode which only includes the color codes when output to a terminal, but not when you pipe the output elsewhere. If you want the colors piped out to something other than stdout, then use --color=always
See the linked article for ways you can change the colour and make grep use this option by default.
Try the --color switch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With