How to print colored output on the terminal
2012-05-20 22:47
471 查看
Procuding colored output on the terminal is very intersting stuff. We produce colored output using escape sequences.
Color codes are used to represent each color. For example, reset=0, black=30, red=31, green=32, yellow=33, blue=34, magenta=35, cyan=36, and white=37.
In order to print colored text, enter the following:
echo -e "e[1;31m This is red text e[0m"
Here e[1;31 is the escape string that sets the color to red and e[0m resets the color back.
Replace 31 with the required color code.
For a colored background, reset=0, black=40, red=41, green=42, yellow=43, blue=44, magenta=45, cyan=46, and white=47, are the color code that are commonly used.
In order to print a colored background, enter the following:
echo -e "e[1;42m Green Background e[0m"
Color codes are used to represent each color. For example, reset=0, black=30, red=31, green=32, yellow=33, blue=34, magenta=35, cyan=36, and white=37.
In order to print colored text, enter the following:
echo -e "e[1;31m This is red text e[0m"
Here e[1;31 is the escape string that sets the color to red and e[0m resets the color back.
Replace 31 with the required color code.
For a colored background, reset=0, black=40, red=41, green=42, yellow=43, blue=44, magenta=45, cyan=46, and white=47, are the color code that are commonly used.
In order to print a colored background, enter the following:
echo -e "e[1;42m Green Background e[0m"
相关文章推荐
- 转:How to Disable the SELinux on RHEL 6
- How to access the features in an in-memory output layer using an IFeatureCursor
- How to set the DefaultButton in a Page Based on ASP.NET Master Page
- How to Maximise CPU Performance for the Oracle Database on Linux
- how to put the text on the left of a radio button in android
- How to design DL model(2):Inception(v4)-ResNet and the Impact of Residual Connections on Learning
- How to install the Sun Java JDK on Ubuntu 10.10
- How to freeze a dynamic aspx page into a static html page (on the server).
- How to Copy and Paste in the Ubuntu Gnome Terminal
- (C#) A demo on how to auto fill out the "account" value in log in web page in "WebBrowser" control.
- How to deploy the ASP.NET MVC 3 website into the IIS7 on Windows server 2008
- Basic Sample - How To Keep ASP.NET ViewState On The Server
- How to prevent the Program Compatibility Assistant from appearing on Windows Vista
- How to Copy and Paste in the Ubuntu Gnome Terminal
- Powershell How to get the Certificate thumbprint data
- How to enable single sign-on service on the SPS
- How To Turn Up Logging on the Siebel Web Server Extension in Siebel Versions 7.x and 8.x? [ID 477185
- How to Install the Latest Nvidia Driver on Ubuntu 12.04
- How to output the message when using the function 'printf'
- [WP7] How to press the mouse on a control, and detect MouseLeftButtonUp on another