I ran into this problem with grep and would like to know if it's a bug or not. The reproducible scenario is a file with the contents:
string
string-
and save it as 'file'. The goal is to use grep with --color=always to output 'string' while excluding 'string-'. Without --color, the following works as expected:
$ grep string file | grep -v string-
but using --color outputs both instances:
$ grep --color=always string file | grep -v string-
I experimented with several variations but it seems --color
breaks the expected behavior. Is this a bug or am I misunderstanding something? My assumption is that passing --color
should have no effect on the outcome.
grep --color=always string file > f
. Now openf
in an editor that can view control characters - there should be some color escape sequences inserted at various, possibly unexpected, locations.--color
is to make a non-visual interface a bit more visual & readable. Which means that it can be seen as a final step in a shell command chain. Consider it the barest nod to the fact that humans need to read this text & we gotta mix it up so the eyes don’t get bored.grep -v string- file | grep --color=always string