bash - Remove escaping sequences automatically while redirecting -


lots of shell tools such grep , ls can print colorful texts in terminal. , when output redirected regular file, escaping sequences representing colors removed , pure texts written file. how achieve that?

use:

if [ -t 1 ] 

to test whether stdout connected terminal. if is, print escape sequences, otherwise print plain text.


Comments

Popular posts from this blog

c++11 - Intel compiler and "cannot have an in-class initializer" when using constexpr -

rest - Spring boot: Request method 'PUT' not supported -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -