Ask Different is a question and answer site for power users of Apple hardware and software. 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

The following produced text with different color on terminal in Lion, but not in Mountain Lion. Why? What can be done to echo in color on Mountain Lion?

echo -e "Some text \e[0;32m in color \e[0m no more color";

In mountain Lion it just prints as if -e wasn't given as an argument to echo.

share|improve this question
Strangely, man echo does not mention the -e flag, even though the -e flag works. At least for \n – Hugo Dec 13 '12 at 16:33
The manage for echo describes the /bin/echo external command, not the echo that is built into the shell that you happen to be using (e.g. the one named in the #! line at the top of your script). You need to consult the manpage for the shell that you are using (probably bash) to see what options its internal echo supports. – Chris Johnsen Dec 14 '12 at 5:31
up vote 6 down vote accepted

As described in the Application Usage section of the POSIX description of the echo command, the -n option and escape sequences are not very portable (due to different support in the various branches of the Unix family tree).

The printf command (which, like echo, is also builtin to most shells, and available as an external command) is more reliably standardized (though the syntax is not the same; e.g. you need to watch for % in the first argument, and multiple arguments are not automatically joined with a space):

printf 'Some text \e[0;32m in color \e[0m no more color\n'

printf '%s \e[0;32m%s\e[0m %s\n' 'Some text' 'in color' 'no more color'
share|improve this answer
Thanks Chris, accepted your answer since it was better than the one I found. – Hugo Dec 19 '12 at 9:09

The problem was that the escape code \e has been removed in mountain lion's version of echo. Change \e to \033 and it will work.

share|improve this answer
This site holds true for Yosemite, cheers much appreciated.. – reevesy Jan 13 '15 at 16:36

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.