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
For me the solution is to use printf, e.g.
printf
echo -e $(printf "\e[32mRed text\e[0m")`
This helped me as well in macOS. Thank you!
Try using -ne rather than -e.
-ne
-e
Try $ echo -e "\033[32mRed text\e[0m" \e[32mRed text\033[0m. i.e. \033 instead \e.
$ echo -e "\033[32mRed text\e[0m" \e[32mRed text\033[0m
\033
\e
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the great article. However in my environment, if I run the example, it will print the escape code literally. e.g.
For me the solution is to use
printf
, e.g.This helped me as well in macOS. Thank you!
Try using
-ne
rather than-e
.Try
$ echo -e "\033[32mRed text\e[0m"
. i.e.\e[32mRed text\033[0m
\033
instead\e
.