Results 1 to 8 of 8
I want to get `echo xxx` output in color, what I have to do for that?...
- 11-20-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
How to get output word in color
I want to get `echo xxx` output in color, what I have to do for that?
- 11-20-2008 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
You have to prefix the output with the 'escape sequence' that'll turn on the color and then postfix with the escape sequence' to turn the color off. For example, to print in blue:
Here's a link with the escape sequences:Code:_esc="\033" _blue="${_esc}[34m" _off="${_esc}[0m" echo "${_blue}xxx${_off}"
ANSI color codes
- 11-20-2008 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Thanks for the quick reply.........
but for me your command dosnt work but when i used echo -en "yourcommand" it worked perfectly
any way thanks alot i got wat i want....
- 11-20-2008 #4Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
can you pls explain me wat is the \033?
- 11-20-2008 #5Linux User
- Join Date
- Jun 2007
- Posts
- 318
Sorry, forgot the -e option. That option does this:
-e enable interpretation of the backslash-escaped characters listed below
In this case:
\NNN the character whose ASCII code is NNN (octal)
033 is the octal value of the escape character.
- 11-20-2008 #6Just Joined!
- Join Date
- Oct 2008
- Location
- Edinburgh, Scotland
- Posts
- 18
You could also do:
the ending resets the screen to original coloursCode:echo -e '\E[37mYour text here' ; tput sgr0
Change the ANSI codes to suit.
- 11-21-2008 #7Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
thanks for the reply........
- 11-21-2008 #8Just Joined!
- Join Date
- Oct 2008
- Location
- Edinburgh, Scotland
- Posts
- 18
You're most welcome


Reply With Quote