How can I use grep command to display both matched and unmatched lines? Matched line should be in red and other lines should be in normal color.
Is there a grep option available to do that?
How can I use grep command to display both matched and unmatched lines? Matched line should be in red and other lines should be in normal color.
Is there a grep option available to do that?
grep --color=always -e pattern -e '$'
If you want to match other lines to have some context, you can use the -A and -B options:
grep --color=always -A 9 -B 9 -e pattern
will give you 9 lines of context. If this is not sufficient, you can increase this value.