What is the default color behavior for
grep --color if no [=WHEN] is specified?
The grep man page states:
Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal. ... WHEN is
Does the default [=WHEN] for
grep --color become:
or does it depend on implementation and platform?
In my tests on Ubuntu 14.04 with GNU grep 2.16:
echo "foo bar" | \grep --color foo
echo "foo bar" | \grep --color foo | \grep --color bar
bar, so it appears that
grep --color=auto is in effect here. I have not tested this on Windows or Mac, however; I don't know if this behavior is universal.
This default for [=WHEN] is a little different from
ls --color where the man page for
colorize the output. WHEN defaults to
alwaysor can be
Here, the behavior of the missing WHEN is explicit.