Folks, I want to know if there exists a command that just highlight some portions of the input text, rather than filtering it like grep
does.
To give an example, suppose the following input text:
foo bar
gaz das
xar
grep "bar\|gaz" input
would print the first two lines, highlighting bar
and gaz
, but would not display xar
.
I'm aware that I could simply set a big constant to the -C
argument, so it would "always" show the context, like: grep -C1000 "bar\|gaz" input
, but I'm not sure if that is efficient, or if there is a better tool for that.
-E
is not needed, you cangrep --color 'pattern\|$' file
– chaos Jan 05 '16 at 13:57