[TriLUG] What happens to console codes in pipes?

Peter Neilson via TriLUG trilug at trilug.org
Wed Sep 19 10:23:10 EDT 2018


On Wed, 19 Sep 2018 09:53:25 -0400, Nathan Yinger via TriLUG  
<trilug at trilug.org> wrote:

> Hello,
>
> While doing some grepping, I noticed something: grep returns colored
> output, but if it is piped through something like sort or sed the colors
> are stripped out.
>
> I am wondering what is stripping the color codes. Is this something the
> shell does to anything that is piped?


Look up 'info ls' and notice what it says about color. The color codes are  
not created for piped output unless you request --color, in which case you  
may get garbage from the next pipe item if it does not know what to do  
with the color escape codes. A bit of experimentation will reveal just  
about everything.


More information about the TriLUG mailing list