linux cli colour codes code example

Example 1: bash change output color

echo -e '\e[31m'	# The output color is now red

Reset = '\e[0m'
Bright = '\e[1m'
Dim = '\e[2m'
Underscore = '\e[4m'
Blink = '\e[5m'
Reverse = '\e[7m'
Hidden = '\e[8m'

FgBlack = '\e[30m'
FgRed = '\e[31m'
FgGreen = '\e[32m'
FgYellow = '\e[33m'
FgBlue = '\e[34m'
FgMagenta = '\e[35m'
FgCyan = '\e[36m'
FgWhite = '\e[37m'

BgBlack = '\e[40m'
BgRed = '\e[41m'
BgGreen = '\e[42m'
BgYellow = '\e[43m'
BgBlue = '\e[44m'
BgMagenta = '\e[45m'
BgCyan = '\e[46m'
BgWhite = '\e[47m'

Example 2: ansi colors

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

Tags:

Java Example