Adding Color to bash

Hey everyone,

I have come across an issue to where I am trying to create a script which changes the text color with a simple if then statement. I have seen it done with Fedora 8 but when I try and create it using my MacBook Pro running Snow Leopard it doesn't work. Funny thing is, when I use the "export PS1=" followed by that script, that color changes. Here is what I have:

if [ $clr = "r" ] ; then 
echo -e "\e[1;31m"

The only thing that happens when this is ran is the "\e[1;31m" is echoed.

The only thing I can think of is that between the fedora and Apple version of BASH are different? Not sure though. If anyone can offer any guidance on this I would greatly appreciate it. Thanks.

try this way

echo "\033[1;31m*************`date`*************** \033[m"

Hey guys,

This works...

#!/bin/bash
if [ $clr="r" ]; then 
    echo -e '\E[1;31m'
    fi

Notes:
Removed surrounding spaces around the '=' (doesn't like extra spaces)
Removed extra space after closing square bracket (not major)
Changed escape character at beginning of string to '\E' (can't remember the difference)
Used single quotes for the string (apparently recommended but optional)
Added 'fi' to terminate the 'if' command (compulsory)

A.