How to print colored output on the terminal

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"

转载于:https://www.cnblogs.com/newstar/archive/2012/05/20/2510950.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值