Coloring Bash Output

I wanted to add some colour to the output of my bash shell script and was able to do so with the following – very simple red and green:

Colour bash shell script output

if [ $COUNT -eq 0 ]; then
tput setaf 2
echo "OK There are no problems"
tput sgr0
else
tput setaf 1
echo "WARNING There are problems"
tput sgr0
fi

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>