There are two ways to bring the echo output color
Define color variables in shell scripts, use ECHO-E to call variables
When defining a variable, define the ECHO-E in the variable, and then output the variable
Shell script that lets echo output display color
#!/bin/bash# defines the color of the variable red_color= ' \e[1;31m ' #红GREEN_COLOR = ' \e[1;32m ' #绿YELOW_COLOR = ' \e[1;33m ' #黄BLUE_COLOR = ' \e[1;34m ' #蓝PINK = ' \e[1;35m ' #粉红RES = ' \e[0m ' # Need to use echo -eecho -e "${red_color}======red color======${res}" echo -e "${yelow_color}======yelow color======${res}" echo -e "${blue_color}======green color ======${res} "echo -e " ${green_color}======green color======${res} "echo -e "${pink}======pink color======${res}" echo "################################################### ########## "#直接把echo -e into the variable, the use of direct output variables can be setcolor_success=" echo -en \\033[1;32m "Setcolor_ Failure= "echo -en \\033[1;31m" setcolor_warning= "echo -en \\033[1;33m" SETCOLOR_NORMAL= "Echo -en \\033[0;39m "echo ----oldboy trainning----- && $ setcolor_successecho ----oldboy trainning----- && $SETCOLOR _failureecho ----Oldboy trainning----- && $SETCOLOR _warningecho ----oldboy Trainning----- && $SETCOLOR _normal
The script execution results are as follows
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/56/BF/wKiom1SMCb2QwDj9AAEajUJn-Fc907.jpg "title=" Echo_ Color.png "alt=" Wkiom1smcb2qwdj9aaeajujn-fc907.jpg "/>
This article from "Plum blossom fragrance from bitter cold" blog, please be sure to keep this source http://wangjunkang.blog.51cto.com/8809812/1589606
Let the echo output in the shell script color