Friday, 5 August 2011

Unix : Display colorful text on screen


Parameter Meaning Example
0 Sets default color scheme (White foreground and Black background), normal intensity, no blinking etc.  
1 Set BOLD intensity $ echo -e "I am \033[1m BOLD \033[0m Person"I am BOLD Person
Prints BOLD word in bold intensity and next ANSI Sequence remove bold effect (\033[0m)
2 Set dim intensity $ echo -e "\033[1m  BOLD \033[2m DIM  \033[0m"
5 Blink Effect $ echo -e "\033[5m Flash!  \033[0m"
7 Reverse video effect i.e. Black foreground and white background in default color scheme $ echo -e "\033[7m Linux OS! Best OS!! \033[0m"
11 Shows special control character as graphics character. For e.g. Before issuing this command press alt key (hold down it) from numeric key pad press 178 and leave both key; nothing will be printed. Now give --> command shown in example and try the above, it works. (Hey you must know extended ASCII Character for this!!!) $ press alt + 178
$ echo -e "\033[11m"
$ press alt + 178
$ echo -e "\033[0m"
$ press alt + 178
25 Removes/disables blink effect  
27 Removes/disables reverse effect  
30 - 37 Set foreground color
31 - RED
32 - Green
xx - Try to find yourself this left as exercise for you :-)
$ echo -e "\033[31m I am in Red"
40 - 47 Set background color
xx - Try to find yourself this left as exercise for you :-)
$ echo -e "\033[44m Wow!!!"

No comments:

Post a Comment