Notes

Colored Output

Edit on GitHub


Bash Scripting
1Start=`\033[`
2Color=`0;32m`
3Close=`0m`

\033[0;32 marks the beginning of color and \0333[0m marks the end.

What you do is:

1echo -e "\033[0;32m This text is green \033[0m"
1echo -e "${StartColor} This text is green ${StartClose}"

NOTE: When referencing variables inside an echo, the -e flag is important. So are the double quotation marks "

In Bash, the <Esc> character can be obtained with the following syntaxes:

  • \e
  • \033
  • \x1B

http://misc.flogisoft.com/bash/tip_colors_and_formatting has very detailed examples with pictures.

ColorCodeColorCode
Black0;30Dark Gray1;30
Red0;31Light Red1;31
Green0;32Light Green1;32
Brown/Orange0;33Yellow1;33
Blue0;34Light Blue1;34
Purple0;35Light Purple1;35
Cyan0;36Light Cyan1;36
Light Gray0;37White1;37cl