I was hoping to see if someone can point out what I am doing wrong because I am stumped. I am trying to learn bash scripting to deploy a dev test server. One of the things I am trying to achieve is outputting status outputs when a part of the script completes or an action completes. As an example:
printf "[ %s ] %s distribution detected. Validated as supported by this script.\n" "$PASSED" "$LINUX_DISTRO"
The problem I am having is formatting the value of the first string, %s, which is $PASSED. In the beginning of the script I have defined $PASSED as
PASSED="\e[32mPASSED\e[0m"
However, when I go to execute the script, the output looks like the following:
[ \e[32mPASSED\e[0m ] CENTOS distribution detected. Validated as supported by this script.
Instead of the correct output which looks like:
[ PASSED ] CENTOS distribution detected. Validated as supported by this script.
Where "PASSED" is written in green coloring.
However, I did notice that if I do the following:
printf "[ $PASSED ] %s distribution detected. Validated as supported by this script.\n" "$LINUX_DISTRO"
The above behaves correctly, but I believe isn't the correct way of doing it. Any ideas?
tputor similar - that's what it's for.tput. Cheers