echo 打印彩色输出

[root@localhost ~]# echo -e "\e[1;31m this is ceshi \e[0m"
this is ceshi
[root@localhost ~]# echo -e "\e[1;42m this is ceshi \e[0m"
this is ceshi
[root@localhost ~]# echo -e "\e[1;45m this is ceshi \e[0m"
this is ceshi

 

字体颜色: 每种颜色都有对应的颜色码。比如:重置=0,黑色=30,红色=31,绿色=32,黄色=33,蓝 色=34,洋红=35,青色=36,白色=37。

背景颜色: 经常使用的颜色码是:重置=0,黑色=40,红色=41,绿色=42,黄色=43, 蓝色=44,洋红=45,青色=46,白色=47。

\e[1;31m将颜色设为红色,\e[0m将颜色重新置回。

 

posted @ 2021-10-18 09:35  拥抱大海,面向天空  阅读(98)  评论(0)    收藏  举报