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

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -