I want to see color output when in stdout to the console, but I want to remove it in a captured copy of the output from the tee
command.
In my case,
command_that_writes_color_to_stdout | tee file
I'd like the file to be clean of ANSI color sequences, etc.,
as it makes grep
ing the log file fun later:
echo -e "color \033[1;31mRED\033[0m output" | tee test.log
In this case, color is written to the console and also into the file "test.log".
color ^[[1;31mRED^[[0m output
Is there a way to strip ANSI sequences only for the tee
's output to file?
Tried to make tee see my terminal is unaware of colors (env vars, sub-shells) but tee
happily just writes what it is given.
I want the color for the console output (for human consumption, it's great)
but do not want color in the log file copy of the output.
echo -e "color \033[1;31mRED\033[0m output" | TERM=dumb tee test.log ; od -c test.log
I found many who want color codes in their "piped to tee" output (usually when the first program is aware of something being able to display color), but I'm not finding an question/answer to do the reverse.