0

To show output in both terminal and to a file, tee can be used like below

ls --color=auto | tee opfile

But now, there is no color in the terminal. If I force colors, opfile also has colors which affects greping and other tools that parse the opfile.

ls --color=always | tee opfile # Now opfile has colors

Is there a way to to have colors in terminal but not in output file? Showing ls for example. Assume it is some command that compiles and spits out errors.

balki
  • 4,407

1 Answers1

0

You can remove colors from the file:

sed -e "s/\x1B[^m]*m//g" opfile
White Owl
  • 5,129