5

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 one

Screen-2:

Screen two

Screen three and four are with logging enabled in the script:

Screen-3:

Screen three

Screen-4:

Screen four

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)

Jags
  • 2,235
  • 3
  • 28
  • 44

0 Answers0