Color changes for echo output

Various Linux Stuff
Post Reply
thockman
Site Admin
Posts: 104
Joined: Thu Dec 15, 2005 5:51 pm
Location: Kansas City
Contact:

Color changes for echo output

Post by thockman » Sat Dec 14, 2013 1:44 pm

Here is a list of color codes:
Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
Purple 0;35 Light Purple 1;35
Brown 0;33 Yellow 1;33
Light Gray 0;37 White 1;37

Here is a sample to use one:

Code: Select all

#!/bin/bash
clear
rc='\e[0;31m' # Red Color
nc='\e[0m' # No Color
nodes="node1 node2 node3"
for i in $nodes; do
  echo "Checking node $i."
  if ! ping -c 1 $i &> /dev/null; then
    echo -e "$rc $i appears to be offline.  Please make sure it is powered on :).$nc"
  else
    echo -e "Looks good"
  fi
done

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest