彩色文本输出
发布时间:2020-12-15 07:06:47 所属栏目:安全 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/bin/bash#输出彩色文字,需要四个参数,分别是前景色,背景色,样式,文字function ColorText(){#判断参数个数,更加严格的判断比如是否超过范围这
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 #!/bin/bash #输出彩色文字,需要四个参数,分别是前景色,背景色,样式,文字 function ColorText() { #判断参数个数,更加严格的判断比如是否超过范围这里就不做详细判断了 if [ $# -ne 4 ] then echo "Usage:4 parameters are needed!" echo "ForeColor,BackgroundClor Style and Text!" ShowHelp; else Fg="3""$1" Bg="4""$2" SetColor="E[""$Fg;$Bg""m" Style=" 33[""$3""m" Text="$4" EndStyle=" 33[0m" echo -e "$SetColor""$Style""$Text""$EndStyle" fi; } #输出帮助信息 function ShowHelp() { echo "The frst parameter is a number ranged from 1 to 10,represents the foreground color." echo "The second parameter is a number ranged from 1 to 10,represents the background color." ColorText 1 8 2 "1 red"; ColorText 2 8 2 "2 green"; ColorText 3 8 2 "3 yellow"; ColorText 4 8 2 "4 blue"; ColorText 5 8 2 "5 magenta"; ColorText 6 8 2 "6 cyan"; ColorText 7 8 2 "7 gray"; ColorText 8 8 2 "8 white"; ColorText 9 8 2 "9 white"; ColorText 10 8 2 "10 black"; echo "The third parameter is a number ranged from 1 to 9,represents the style of the characters." ColorText 10 8 1 "1 lighter,and bold"; ColorText 10 8 4 "4 draw a line under the string."; ColorText 10 8 7 "7 swap the foreground color and the background color"; ColorText 10 8 9 "9 draw a deleting line"; ColorText 10 8 9 "others normal style"; echo "The fourth parameter is the content you wanna clolor,a string." } ColorText 1 8 2 'Test' #ColorText 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- tensorflow – 如何直接写入模仿scalar_summary的摘要?
- 在Scala中创建一个Map String – > Function
- angularjs – 如何在使用createDialog时将动态数据传递给模
- Bash脚本,检查错误,记录
- git 删除分支和回滚的实例详解
- asp.net – Docker pull显示“Unknown blob”
- lisp – Innexior Shell或UIOP:与后台进程交互
- bootstrap-datepicker限定可选时间范围
- scala – mapValues和Map中的变换之间的差异
- angular – TSLint – 您只能绑定到公共类成员(templates-u