I was hoping to find out if anyone could indicate what I'm doing wrong, because I'm at a dead end. I am trying to learn a bash script to deploy a dev test server. One of the things I'm trying to achieve is to output status outputs when part of the script completes or the action completes. As an example:
printf "[ %s ] %s distribution detected. Validated as supported by this script.\n" "$PASSED" "$LINUX_DISTRO"
The problem I am facing is formatting the value of the first line %s, which $PASSED. At the beginning of the script, I defined $PASSEDas
PASSED="\e[32mPASSED\e[0m"
However, when I go to execute the script, the output is as follows:
[ \e[32mPASSED\e[0m ] CENTOS distribution detected. Validated as supported by this script.
Instead of the correct output, which looks like this:
[ PASSED ] CENTOS distribution detected. Validated as supported by this script.
Where "PASSED" is written in green.
However, I noticed that if I do the following:
printf "[ $PASSED ] %s distribution detected. Validated as supported by this script.\n" "$LINUX_DISTRO"
, , . ?