Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run a simple shell script with the following code:

#!/bin/sh 
printf "\e[32m Hello World\n"

I get

\e[32m Hello World

as output as opposed to a green Hello World output.

share|improve this question
    
I tried this command and it works just fine for me. –  Wuffers Jun 21 '11 at 17:36
    
it doesnt work if i run it as part of a shell script –  robin smith Jun 21 '11 at 17:37

1 Answer 1

printf doesn't understand \e; you need to use \033. Note that printf is also a bash builtin; that one has GNU extensions including \e, but unless you specifically request your script be run by /bin/bash you will usually get the POSIX one.

share|improve this answer

Your Answer

 
discard

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.