控制输出颜色的shell脚本
实现代码:
#!/bin/sh
#ANSIColor--Usethesevariablestomakeoutputindifferentcolors
#andformats.Colornamesthatendwith'f'areforeground(text)colors,
#andthoseendingwith'b'arebackgroundcolors.
initializeANSI()
{
esc="\033"#ifthisdoesn'twork,enteranESCdirectly
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}Thisisaphraseinyellow${redb}andred${reset}
echo-e${boldon}Thisisbold${ulon}thisisitalics${reset}byebye
echo-e${italicson}Thisisitalics${italicsoff}andthisisnot
你了解了后以后及可以写出带颜色,很炫的脚本了
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下