linux 中 echo的颜色输出
echo: 字体颜色 和 背景颜色。
常见的字体颜色:重置=0,黑色=30,红色=31,绿色=32,黄色=33,蓝色=34,紫色=35,天蓝色=36,白色=37。
常见的背景颜色:重置=0,黑色=40,红色=41,绿色=42,黄色=43,蓝色=44,紫色=45,天蓝色=46,白色=47。
字体控制选项:1表示高亮,4表示下划线,5表示闪烁等。
因为需要使用特殊符号,所以需要配合-e选项来识别特殊符号。
001、
[root@PC1 test01]# echo -e "\e[1;41m Red Bcakground \e[0m" ## 其中1表示高亮; 41m表示背景红色 Red Bcakground [root@PC1 test01]# echo -e "\e[4;41m Red Bcakground \e[0m" ## 其中4表示下划线 Red Bcakground
002、改变背景色;42 绿色背景
[root@PC1 test01]# echo -e "\e[1;41m Red Bcakground \e[0m" Red Bcakground [root@PC1 test01]# echo -e "\e[1;42m Red Bcakground \e[0m" ## 42表示绿色背景,1高亮 Red Bcakground [root@PC1 test01]# echo -e "\e[4;42m Red Bcakground \e[0m" ## 4表示下划线 Red Bcakground
003、测试背景色
[root@PC1 test01]# echo -e "\e[1;41m Red Bcakground \e[0m" ## 41 红色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;40m Red Bcakground \e[0m" ## 40 黑色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;0m Red Bcakground \e[0m" ## 0 重置 Red Bcakground [root@PC1 test01]# echo -e "\e[1;42m Red Bcakground \e[0m" ## 42 绿色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;43m Red Bcakground \e[0m" ## 43 黄色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;44m Red Bcakground \e[0m" ## 44 蓝色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;45m Red Bcakground \e[0m" ## 45 紫色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;46m Red Bcakground \e[0m" ## 46 天蓝色 Red Bcakground [root@PC1 test01]# echo -e "\e[1;47m Red Bcakground \e[0m" ## 47 白色 Red Bcakground [root@PC1 test01]# echo -e "\e[5;47m Red Bcakground \e[0m" ## 5 表示闪烁 Red Bcakground
004、测试字体颜色
[root@PC1 test01]# echo -e "\e[1;30m linux \e[0m" ## 30 黑色 linux [root@PC1 test01]# echo -e "\e[1;31m linux \e[0m" ## 31 红色 linux [root@PC1 test01]# echo -e "\e[1;32m linux \e[0m" ## 32 绿色 linux [root@PC1 test01]# echo -e "\e[1;33m linux \e[0m" ## 33 黄色 linux [root@PC1 test01]# echo -e "\e[1;34m linux \e[0m" ## 34 蓝色 linux [root@PC1 test01]# echo -e "\e[1;35m linux \e[0m" ## 35 紫色 linux [root@PC1 test01]# echo -e "\e[1;36m linux \e[0m" ## 36 天蓝色 linux [root@PC1 test01]# echo -e "\e[1;37m linux \e[0m" ## 37 白色 linux
005、任意一个\e都可以使用\033进行替换
[root@PC1 test01]# echo -e "\e[1;47m Red Bcakground \e[0m" Red Bcakground [root@PC1 test01]# echo -e "\033[1;47m Red Bcakground \033[0m" Red Bcakground
。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
2022-06-22 R语言中实现在命令行中传参
2022-06-22 R语言中read.table中colClasses = "character"选项作用
2021-06-22 c语言中以10进制、8进制、16进制显示同一个数字