We can use the following colors' codes:
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/Orange 0;33 Yellow 1;33
Light Gray 0;37 White 1;37
And then use them like this in your script:
red='\e[0;31m'
NC='\e[0m' # No Color
echo -e "${red}Hello Stackoverflow${NC}"
Keep in mind you have to use '-e' after 'echo' and use double quote(") for text.
Set
Code Description Example Preview
1 Bold/Bright echo -e "Normal \e[1mBold"

2 Dim echo -e "Normal \e[2mDim"

4 Underlined echo -e "Normal \e[4mUnderlined"

5 Blink 1) echo -e "Normal \e[5mBlink"

7 Reverse (invert the foreground and background colors) echo -e "Normal \e[7minverted"

8 Hidden (usefull for passwords) echo -e "Normal \e[8mHidden"

Reset
| Code | Description | Example | Preview |
|---|---|---|---|
| 0 | Reset all attributes | echo -e "\e[0mNormal Text" | |
| 21 | Reset bold/bright | echo -e "Normal \e[1mBold \e[21mNormal" | |
| 22 | Reset dim | echo -e "Normal \e[2mDim \e[22mNormal" | |
| 24 | Reset underlined | echo -e "Normal \e[4mUnderlined \e[24mNormal" | |
| 25 | Reset blink | echo -e "Normal \e[5mBlink \e[25mNormal" | |
| 27 | Reset reverse | echo -e "Normal \e[7minverted \e[27mNormal" | |
| 28 | Reset hidden | echo -e "Normal \e[8mHidden \e[28mNormal" |
Foreground (text)
Code Color Example Preview 39 Default foreground color echo -e "Default \e[39mDefault"30 Black echo -e "Default \e[30mBlack"31 Red echo -e "Default \e[31mRed"32 Green echo -e "Default \e[32mGreen"33 Yellow echo -e "Default \e[33mYellow"34 Blue echo -e "Default \e[34mBlue"35 Magenta echo -e "Default \e[35mMagenta"36 Cyan echo -e "Default \e[36mCyan"37 Light gray echo -e "Default \e[37mLight gray"90 Dark gray echo -e "Default \e[90mDark gray"91 Light red echo -e "Default \e[91mLight red"92 Light green echo -e "Default \e[92mLight green"93 Light yellow echo -e "Default \e[93mLight yellow"94 Light blue echo -e "Default \e[94mLight blue"95 Light magenta echo -e "Default \e[95mLight magenta"96 Light cyan echo -e "Default \e[96mLight cyan"97 White echo -e "Default \e[97mWhite"Background
Code Color Example Preview 49 Default background color echo -e "Default \e[49mDefault"40 Black echo -e "Default \e[40mBlack"41 Red echo -e "Default \e[41mRed"42 Green echo -e "Default \e[42mGreen"43 Yellow echo -e "Default \e[43mYellow"44 Blue echo -e "Default \e[44mBlue"45 Magenta echo -e "Default \e[45mMagenta"46 Cyan echo -e "Default \e[46mCyan"47 Light gray echo -e "Default \e[47mLight gray"100 Dark gray echo -e "Default \e[100mDark gray"101 Light red echo -e "Default \e[101mLight red"102 Light green echo -e "Default \e[102mLight green"103 Light yellow echo -e "Default \e[103mLight yellow"104 Light blue echo -e "Default \e[104mLight blue"105 Light magenta echo -e "Default \e[105mLight magenta"106 Light cyan echo -e "Default \e[106mLight cyan"107 White echo -e "Default \e[107mWhite"
Comments