initailizeANSI()
{
esc=""
blackf="${esc}[30m"; redf="${esc}[31m";greenf="${esc}[32m";yellowf="${esc}[33m";bluef="${esc}[34m";
purplef="${esc}[35m";cyanf="${esc}[36m";whitef="${esc}[30m";
blackb="${esc}[40m"; redb="${esc}[41m";greenb="${esc}[42m";yellowb="${esc}[43m";blueb="${esc}[44m";
purpleb="${esc}[45m";cyanb="${esc}[46m";whiteb="${esc}[47m";
boldon="${esc}[1m";boldoff="${esc}[22m";
italicson="${esc}[3m"; italicsoff="${esc}[23m";
ulon="${esc}[4m";uloff="${esc}[5m";
invon="${esv}[7m";invofff="${esc}[27m"
reset="${esc}[0m"
}
initailizeANSI
cat << EOF
${yellowf}This is a phrase in yellow and ${greenf}green${reset}
${bluef}This is a phrase in blue and ${cyanf}cyan${reset}
${purplef}This is a phrase in purple and ${redf}red${reset}
${blackb}This is a phrase in black and ${whiteb}white${reset}
${bloden}This is blod${ulon} this is italics${reset}
EOF
运行结果