Coloring Output[edit | edit source]

To color your shell script output, you will need to echo out an escape sequence that looks something like \033[$color1;$color2;$stylem.

You can specify one or more colors or styles by delimiting the colors or styles with a semicolon and end the list with a 'm'.

Color is given as:

Color Foreground Background
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47

Style is given by:

Style Code
Normal 0
Bold 1
Underline 4

Examples[edit | edit source]

Try these examples by echoing them in a terminal.

To print something as underlined green:

$ echo "\033[33;4mYellow Underlined Text\033[0m"

To print something underlined, red, with a blue background:

$ echo "\033[31;44;4mRed Underlined with a Blue Background Text\033[0m"

To print the above without the underline, just remove the '4' style

$ echo "\033[31;44mRed with a Blue Background Text\033[0m"