码迷,mamicode.com
首页 > 系统相关 > 详细

shell echo颜色例子

时间:2016-04-18 15:32:08      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
## test color for script
RED_COLOR=‘\E[1;31m‘
GREEN_COLOR=‘\E[1;32m‘
YELLOR_COLOR=‘\E[1;33m‘
BLUE_COLOR=‘\E[1;34m‘
PINK=‘\E[1;35m‘
RES=‘\E[0m‘
if [ $# -eq 2 ]
then
echo "Usage:`basename $0` content {red|blue|yellow|pink|res|green}"
exit 1
fi
function echo_color(){
case $2 in
red|RED)
echo -e "${RED_COLOR}$1${RES}"
;;
green|GREEN)
echo -e "${GREEN_COLOR$1${RES}}"
;;
yellow|YELLOW)
echo -e "${YELLOW_COLOR}$1${RES}"
;;
BLUE|blue)
echo -e "${BLUE_COLOR}$1${RES}"
;;
PINK|pink)
echo -e "${PINK}$1${RES}"
;;
*)
echo -e "${PINK}$1${RES}"
esac
}
echo_color abc red
echo_color def pink

shell echo颜色例子

标签:

原文地址:http://www.cnblogs.com/xiewb/p/5404291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!