Home

Colorful logs in Bash

Here's a cheat sheet

NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'

Example of usage in a script:

BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'

echo -e "${BLUE}Downloading the file from server...${NOCOLOR}"
echo -e "${RED}Error downloading file(s)...${NOCOLOR}"
echo -e "${YELLOW}Compiling...${NOCOLOR} hello.c"


Last Updated on

Next Post: Rules vs Guidelines →

Comments