Shell – printing colored text using echo

echoscriptingshell-script

I know that for printing a colored text using echo, for example red color, the code is: echo -e "\e[1;31m This is red text \e[0m"
and I know that in this example, 31 is code of red color and the number of other colors is:

Black       0;30     Dark Gray     1;30
Blue        0;34     Light Blue    1;34
Green       0;32     Light Green   1;32
Cyan        0;36     Light Cyan    1;36
Red         0;31     Light Red     1;31
Purple      0;35     Light Purple  1;35
Brown       0;33     Yellow        1;33
Light Gray  0;37     White         1;37

and for background colors, the num is 40 to 47

my Question is this: what does \e and [ and m(after 31) exactly mean here?
I read in the man page that \e is escape, but I didn't understand what it means.

Best Answer

They are part of the 'Sequence elements' of ANSI escape sequences also known as ECMA-48 CSI sequences which were originally adopted in 1976

More specifically the [ is the 'Control Sequence Introducer'

Type man console_codes in almost any *nix distro to see the codes and some docs.

Related Question