echo输出颜色字体

基本格式:
echo -e “\033[字背景颜色;文字颜色m字符串\033[0m”
样例:
echo -e “\033[1;32mhello\033[0m”

#!/bin/bash
xmessage()
{
        echo -e "\033[1;$1m`date "+[%Y/%m/%d %H:%M:%S]"`$2\033[0m"

}

msg_debug(){
        xmessage 30 "[DBG]$*"
}

msg_error(){
        xmessage 31 "[ERROR]$*"
}

msg_success(){
        xmessage 32 "[SUC]$*"
}

msg_warn(){
        xmessage 33 "[WARN]$*"
}

msg_show(){
        xmessage 34 "[MSG]$*"
}

msg_debug "this is debug message"
msg_error "fatal error"
msg_success "success"
msg_warn "something wrong"
msg_show "show sth."

 

你可能感兴趣的:(echo输出颜色字体)