打印文字颜色方法 - yuzhouxiaogegit/blog GitHub Wiki

打印文字颜色方法

1、打印红色 echoTxtColor "常用shell脚本方法封装" "red"

2、打印绿色 echoTxtColor "常用shell脚本方法封装" "green"

3、打印黄色 echoTxtColor "常用shell脚本方法封装" "yellow"

# 打印文字颜色方法
echoTxtColor(){
	colorV="1"
	if [ $2 = 'red' ](/yuzhouxiaogegit/blog/wiki/-$2-=-'red'-);
	then
		colorV="1"
	elif [ $2 = 'green' ](/yuzhouxiaogegit/blog/wiki/-$2-=-'green'-);
	then
		colorV="2"
	elif [ $2 = 'yellow' ](/yuzhouxiaogegit/blog/wiki/-$2-=-'yellow'-);
	then
		colorV="3"
	fi
	echo -e "\033[3${colorV}m ${1} \033[0m"
}
# 调用示例

echoTxtColor "常用shell脚本方法封装" "green"