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

首頁 > 系統 > Linux > 正文

控制輸出顏色的shell腳本

2019-10-26 18:48:35
字體:
來源:轉載
供稿:網友

實現代碼:

#!/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"}

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

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

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阳信县| 台南县| 丹巴县| 北海市| 新晃| 青田县| 如皋市| 逊克县| 陇南市| 涟水县| 巴彦淖尔市| 延长县| 大宁县| 霞浦县| 青田县| 凤翔县| 娄烦县| 仁布县| 依安县| 延庆县| 通城县| 专栏| 祁连县| 合作市| 江山市| 金门县| 白朗县| 嘉峪关市| 甘南县| 易门县| 赤峰市| 揭阳市| 黑水县| 剑川县| 石河子市| 长海县| 临泉县| 新蔡县| 东乡| 太和县| 八宿县|