DEV Community

Discussion on: Adding colors to Bash scripts

Collapse
jianwu profile image
jianwu

Thanks for the great article. However in my environment, if I run the example, it will print the escape code literally. e.g.

$ echo -e "\e[32mRed text\e[0m"
\e[32mRed text\e[0m
Enter fullscreen mode Exit fullscreen mode

For me the solution is to use printf, e.g.

echo -e $(printf "\e[32mRed text\e[0m")`
Enter fullscreen mode Exit fullscreen mode