The echo display in the shell script is displayed in color with the echo displayed in color with the parameter-E
The format is as follows:
Copy Code code as follows:
Echo-e "\033[character background color; text color m string \033[0m"
For example:
Copy Code code as follows:
Echo-e "\033[41;36m something here \033[0m"
41 of the positions represent the background, and 36 of the position is the color of the word.
Note:
1, the word background color and the text color is in English ""
2. There's a m behind the text color.
3, the string can be no space before and after, if any, the output is also a space
Below is the corresponding word and background color, you can try to find out the different color matching
Cases
Copy Code code as follows:
Echo-e "\033[31m Red word \033[0m"
Echo-e "\033[34m Yellow word \033[0m"
Echo-e "\033[41;33m Red bottom yellow word \033[0m"
Echo-e "\033[41;37m Red bottom White \033[0m"
Word Color: 30-–37
Copy Code code as follows:
Echo-e "\033[30m black word \033[0m"
Echo-e "\033[31m Red word \033[0m"
Echo-e "\033[32m Green word \033[0m"
Echo-e "\033[33m Yellow word \033[0m"
Echo-e "\033[34m Blue word \033[0m"
Echo-e "\033[35m Purple word \033[0m"
Echo-e "\033[36m Blue word \033[0m"
Echo-e "\033[37m white word \033[0m"
Word background color range: 40-–47
Copy Code code as follows:
Echo-e "\033[40;37m black background white \033[0m"
Echo-e "\033[41;37m Red bottom White \033[0m"
Echo-e "\033[42;37m Green background white \033[0m"
Echo-e "\033[43;37m Yellow background white \033[0m"
Echo-e "\033[44;37m Blue background white \033[0m"
Echo-e "\033[45;37m Purple background white \033[0m"
Echo-e "\033[46;37m Blue background white \033[0m"
Echo-e "\033[47;30m White bottom black word \033[0m"
Final Control Options Description
Copy Code code as follows:
\33[0m Turn off all properties
\33[1m Set High brightness
\33[4m Underline
\33[5m Flashing
\33[7M Reverse Display
\33[8m Hidden
\33[30m-\33[37m Set Foreground color
\33[40m-\33[47m Set Background color
\33[na cursor up N line
\33[NB cursor Move n line down
\33[NC cursor Right n row
\33[nd Cursor Left n line
\33[Y;XH Set Cursor Position
\33[2J Clear Screen
\33[k clears the contents from the cursor to the end of the line
\33[s Save Cursor position
\33[u Restore cursor Position
\33[?25l Hide Cursor
\33[?25h Display cursor