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
Post a Comment