Outout in Colors
iDog
We can print strings in colors by using escape sequence:
echo "^[[0;36;40mXXXXXX^[[0m"
Notes:
- "^[[" contains two characters: an Esc (press <Ctrl>-V, then Esc key), and a '['.
- We need to 'close' the color instruction by ending with "^[[0m", otherwise the color is to be used in all the terminal.
Syntax:
^[[<attr>;<fore_color>;<back_color>m
If any of the above three values is omitted, then the default value is used.
Attributes
Value | Meaning |
0 | Reset All Attributes (return to normal mode) |
1 | Bright (Usually turns on BOLD) |
2 | Dim |
3 | Underline |
5 | Blink |
7 | Reverse |
8 | Hidden |
Foreground colors
Value | Meaning |
30 | Black |
31 | Red |
32 | Green |
33 | Yellow |
34 | Blue |
35 | Magenta |
36 | Cyan |
37 | White |
Background colors
Value | Meaning |
40 | Black |
41 | Red |
42 | Green |
43 | Yellow |
44 | Blue |
45 | Magenta |
46 | Cyan |
47 | White |