Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I added my script called to /bin/ folder. My script contains code that echos text with different text colors. But when I run my script like

$ mylovelyscript

it executes in bash mode. So, my script give an output with the texts with color codes, like

\e[93mHello World!

but not colored texts. But when I run my script like $ sh with sh command, it executes like how I want. Now, I want my script to give me colored texts like in sh mode, but in this case I want to call my script like $ mylovelyscript, not like $ sh mylovelyscript. How can I do it? Thanks!

share|improve this question
up vote 2 down vote accepted

Put this line at the beginning of the file:




share|improve this answer
Thanks @Wutaz! I think that it will work. I have a one problem, not related with this problem: I switched to sh mode, as you said, but know I need to change bash code to sh code, as sh can't read bash style code. – Ziyaddin Sadigov Feb 26 '14 at 18:17
Didn't you say you were running it with sh? – Wutaz Feb 26 '14 at 18:22
no, I was running it with bash, I need to do it on sh, in my script there is for...loop which I wrote for bash, I need to change it for sh mode. – Ziyaddin Sadigov Feb 26 '14 at 18:27
is there any way to do it in bash mode? To make colored texts in bash mode? – Ziyaddin Sadigov Feb 26 '14 at 18:43
You said you ran it with $ sh – Wutaz Feb 26 '14 at 20:23

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.