Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I type below command in the shell I get the OUTPUT in green color.


echo "\033[32mCONNECTING TO abpwrk\033[m";

Output(in green color)


But if I use the same statement in a small one line script and execute it.Then I get the output(in white color).

\033[32mCONNECTING TO abpwrk\033[m

What am I missing in the script.Do I need to define some extra parameters to initiate colors ? I am using k-shell.

share|improve this question
Post your script. I am sure that one is not interpreted by ksh. Try echo -e "\033[32mCONNECTING TO abpwrk\033[m" – if that works, your script is probably interpreted by bash. – manatwork Oct 26 '12 at 12:21
It worked.Thanks – g4ur4v Oct 26 '12 at 12:33

You probably are using different shells with different echo implementations. At least in bash's implementation of echo, interpretation of escape sequences is not enabled by default (you have to enable it with the -e switch).

In any case, printf is generally more conformant between environments. Try using the following instead:

_host=abpwrk ; printf '\033[32mCONNECTING TO %s\033[m\n' "$_host"
share|improve this answer
What about tput setaf and tput setab (both followed by a digit)? @g4ur4v: Check out this question. – Emanuel Berg Oct 27 '12 at 0:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.