I'm trying to add color output to my errors in a bash script that I have running on a mac. The problem is the colors are not working. I created the simplest of scripts to demonstrate that it does not work:
#!/bin/bash
echo -e "\e[1;31m This is red text \e[0m"
However, when i run it, I see no colors at all, as shown in this image. The color output of the ls command is working fine however.
Use \033
or \x1B
instead of \e
to represent de <Esc>
character.
echo -e "\033[1;31m This is red text \033[0m"
See http://misc.flogisoft.com/bash/tip_colors_and_formatting