1,105,585 Community Members

Colored output in bash?

Member Avatar
mmiikkee12
Posting Whiz in Training
264 posts since Oct 2004
Reputation Points: 1 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

Anyone know how to put colored text on the screen in a bash script?

Member Avatar
mawe
Junior Poster
133 posts since Sep 2005
Reputation Points: 6 [?]
Q&As Helped to Solve: 73 [?]
Skill Endorsements: 1 [?]
 
0
 

Hi!

Use escape sequences: echo -e '\E[color1;color2mYour Text.'
(color1 is the foreground, color2 the background color)

echo -e '\E[30m black \E[31mred \E[32mgreen \E[33myellow \E[34mblue \E[35mmagenta \E[36mcyan \E[37mwhite'
 echo -e '\E[30;41mblack on red'
Color:           Foreground:           Background:
---------------------------------------------------------
black             30                       40
red               31                       41
green             32                       42
yellow            33                       43
blue              34                       44
magenta           35                       45
cyan              36                       46
white             37                       47

Regards, mawe

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article