Colored output in bash?

Reply

Join Date: Oct 2004
Posts: 274
Reputation: mmiikkee12 is an unknown quantity at this point 
Solved Threads: 5
mmiikkee12's Avatar
mmiikkee12 mmiikkee12 is offline Offline
Posting Whiz in Training

Colored output in bash?

 
0
  #1
Sep 28th, 2005
Anyone know how to put colored text on the screen in a bash script?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 133
Reputation: mawe is an unknown quantity at this point 
Solved Threads: 58
mawe mawe is offline Offline
Junior Poster

Re: Colored output in bash?

 
0
  #2
Sep 29th, 2005
Hi!

Use escape sequences: echo -e '\E[color1;color2mYour Text.'
(color1 is the foreground, color2 the background color)
Shell Scripting Syntax (Toggle Plain Text)
  1. echo -e '\E[30m black \E[31mred \E[32mgreen \E[33myellow \E[34mblue \E[35mmagenta \E[36mcyan \E[37mwhite'
  2. echo -e '\E[30;41mblack on red'
Shell Scripting Syntax (Toggle Plain Text)
  1. Color: Foreground: Background:
  2. ---------------------------------------------------------
  3. black 30 40
  4. red 31 41
  5. green 32 42
  6. yellow 33 43
  7. blue 34 44
  8. magenta 35 45
  9. cyan 36 46
  10. white 37 47
Regards, mawe
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC