国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 大冶市| 全南县| 泰宁县| 合川市| 东乌| 江达县| 行唐县| 盱眙县| 息烽县| 来凤县| 谷城县| 修武县| 蒙山县| 应城市| 曲阳县| 方山县| 雅安市| 呼伦贝尔市| 龙门县| 潢川县| 汶上县| 景德镇市| 舒兰市| 高要市| 岳阳县| 龙川县| 文山县| 遵义市| 永兴县| 梅河口市| 合肥市| 桓仁| 乐都县| 南江县| 山西省| 雅安市| 峨眉山市| 浦东新区| 伊川县| 诏安县| 安图县|