To print colored text in linux terminal

echo "$(tput setaf 1) Hello $(tput setaf 2) World! $(tput sgr0)"
or
echo -e "\033[31m Hello \033[32m World! \033[0m"

Option -e means "enable interpretation of backslash escapes"

No comments: