国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > Linux Shell > 正文

控制輸出顏色的shell腳本

2020-07-27 19:01:46
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

實(shí)現(xiàn)代碼:

#!/bin/sh# ANSI Color -- Use these variables to make output in different colors# and formats. Color names that end with 'f' are foreground (text) colors,# and those ending with 'b' are background colors.initializeANSI(){ esc="/033" # if this doesn't work, enter an ESC directly blackf="${esc}[30m";  redf="${esc}[31m";  greenf="${esc}[32m" yellowf="${esc}[33m"  bluef="${esc}[34m";  purplef="${esc}[35m" cyanf="${esc}[36m";  whitef="${esc}[37m" blackb="${esc}[40m";  redb="${esc}[41m";  greenb="${esc}[42m" yellowb="${esc}[43m"  blueb="${esc}[44m";  purpleb="${esc}[45m" cyanb="${esc}[46m";  whiteb="${esc}[47m" boldon="${esc}[1m";  boldoff="${esc}[22m" italicson="${esc}[3m"; italicsoff="${esc}[23m" ulon="${esc}[4m";   uloff="${esc}[24m" invon="${esc}[7m";   invoff="${esc}[27m" reset="${esc}[0m"}

先定義函數(shù),接著初始化下函數(shù),接著你就可以看到效果了。
執(zhí)行

echo -e ${yellowf}This is a phrase in yellow${redb} and red${reset}
echo -e ${boldon}This is bold${ulon} this is italics${reset} bye bye
echo -e ${italicson}This is italics${italicsoff} and this is not

你了解了后以后及可以寫(xiě)出帶顏色,很炫的腳本了

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 香港 | 宁国市| 绍兴市| 东丰县| 泌阳县| 嘉荫县| 河曲县| 永宁县| 淅川县| 江口县| 伊宁县| 明星| 乃东县| 稻城县| 耒阳市| 上饶县| 南雄市| 宁阳县| 闻喜县| 盈江县| 吉首市| 顺平县| 景洪市| 曲松县| 宝山区| 乌苏市| 布尔津县| 普安县| 卫辉市| 开江县| 金昌市| 洛南县| 永春县| 遂川县| 合肥市| 竹北市| 静安区| 平阴县| 咸丰县| 景洪市| 富民县|