I would like to preserve colors, in console, of a Bash script output, while logging and echo it to console.
When I run a script with the following code, I lose colors in console.
LOG_FILE="Merge.log"
touch $LOG_FILE
exec > >(tee $LOG_FILE) 2>&1;
Here are screenshots to make it clear:
Screen one and two are with logging disabled (commented out) in the script:
Screen-1:
Screen-2:
Screen three and four are with logging enabled in the script:
Screen-3:
Screen-4:
I have searched quite a lot but couldn't find any solution. Thanks.
OS: Ubuntu MATE 21.04
Bash version: 5.1.4(1)-release (x86_64-pc-linux-gnu)
0 Answers