BASH change color of text ?

andy baxter andy at earthsong.free-online.co.uk
Tue Mar 11 21:05:17 UTC 2008


dave selby wrote:
> Hi all,
>
> I need to change the terminal text color when printing a warning. So
> far in python the following works a treat ...
>
> print """
> \033[1;32mAll configurations have been regenerated and reloaded.
>
> \033[1;31m*WARNING* If you have changed
> ../apache2_config/kmotion_vhost_template you need to :\n
> sudo /etc/init.d/apache2 restart\033[1;37m\n
> """
>
> However I need a bash script to do the same ...
>
> dave at dev-machine:/var/lib/kmotion/daemons$ print "\033[1;32mkmotion
> has been started\033[1;37m"
> Warning: unknown mime-type for "\033[1;32mkmotion has been
> started\033[1;37m" -- using "application/*"
> Error: no such file "\033[1;32mkmotion has been started\033[1;37m"
> dave at dev-machine:/var/lib/kmotion/daemons$
>
> Can anyone tell me how to get this to work via bash print ?
>
> Cheers
>
> dave
>   
try 'echo -e' instead of print (or use printf but this is slightly 
slower as it's not a shell built-in)




More information about the ubuntu-users mailing list