There are typically[0] 3 arguments that can be used with the --color
option to grep
: "auto", "always", and "none". It seems like your grep
may be aliased to use --color always
, in which case the ANSI escape codes used to colorize the output are interfering with ls
's ability to show them. When you use --color=none
, you tell grep
not to use these, fixing your problem. The auto
option is a good compromise: it says to use color when the output is a terminal, but not to if the output is a file or pipeline, or generally something else where the ANSI codes will not work as intended.
That said, slhck is right and you probably don't need to be piping the output of grep
to anything in this case, but it's good to understand the color-related issues for the future.
[0] I say typically, because my man page says you can use "never", "always", and "auto". Perhaps "none" and "never" are synonyms.