Linux bash script color text


Recently in a script I am trying to coloured text in one of the script.

I have been tried couple of ways, failed initially and at the end I got solution.

Content of my script is following:

echo -e "\e[0;32;47m Hello World \e[0m"

After running the script the expected output in Gray background and text is in parrot green colour.

When I ran command sh output is:

-e \e[0;32;47m Hello World \e[0m

The output here is as not expected, reason I fond is shell wont support the coloured text.

Now I ran the command bash and the output is appeared as expected.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s