Linux 中 echo 命令 将字体输出颜色

 

001、示例

(base) [root@pc1 test]# echo -e "\033[47;30m xxxxx \033[0m"   ## 47 表示背景色;30表示字体颜色
 xxxxx

 

002、取消背景色

(base) [root@pc1 test]# echo -e "\033[30m xxxxx \033[0m"       ## 取消背景色, 字体为黑色
 xxxxx
(base) [root@pc1 test]# echo -e "\033[31m xxxxx \033[0m"       ## 取消背景色, 字体为红色
 xxxxx

 

003、输出绿色字

(base) [root@pc1 test]# echo -e "\033[32m xxxxx \033[0m"
 xxxxx

 

004、其他字体颜色

复制代码
(base) [root@pc1 test]# echo -e "\033[33m xxxx \033[0m"        ## 黄色字体
 xxxx
(base) [root@pc1 test]# echo -e "\033[34m yyyy \033[0m"        ## 蓝色字体
 yyyy
(base) [root@pc1 test]# echo -e "\033[35m aaaa \033[0m"        ## 紫色字体 
 aaaa
(base) [root@pc1 test]# echo -e "\033[36m xxxx \033[0m"        ## 亮蓝色字体
 xxxx
(base) [root@pc1 test]# echo -e "\033[37m xxxx \033[0m"        ## 白色字体
 xxxx
复制代码

 

005、背景和字体颜色组合

复制代码
(base) [root@pc1 test]# echo -e "\033[40;37m xxxx \033[0m"        ## 黑底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[41;37m xxxx \033[0m"        ## 红底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[42;37m xxxx \033[0m"        ## 绿底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[43;37m xxxx \033[0m"        ## 黄底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[44;37m xxxx \033[0m"        ## 蓝底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[45;37m xxxx \033[0m"        ## 紫底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[46;37m xxxx \033[0m"        ## 亮蓝底白字
 xxxx
(base) [root@pc1 test]# echo -e "\033[47;30m xxxx \033[0m"        ## 白底黑字
 xxxx
复制代码

 。

 

参考:

01、https://blog.csdn.net/qq_33023953/article/details/130834772

 

posted @   小鲨鱼2018  阅读(313)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2022-11-15 python 中 循环结构同时传入多个参数
2022-11-15 python 中统计每一个字符串中每一个字符出现的次数
2022-11-15 Python 中的 defaultdict 数据类型
2022-11-15 python 中 filter函数的用法
2022-11-15 python 中内建函数map的用法
2020-11-15 ansible
点击右上角即可分享
微信分享提示