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

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -