1、输出字体颜色库

#!/bin/bash

export black='\E[0m\c'
export boldred='\E[1;31m\c'
export boldgreen='\E[1;32m\c'
export boldyellow='\E[1;33m\c'
export boldblue='\E[1;34m\c'
export boldmagenta='\E[1;35m\c'
export boldcyan='\E[1;36m\c'

c_notify=$boldgreen   #通过变量来修改颜色
c_error=$boldred

cecho()
{
        message=$1
        color=${2:-$black}

        echo -e "$color"
        echo -e "$message"
        tput sgr0                       # Reset to normal.
        echo -e "$black"
        return
}

cecho "1. #################" $boldred
cecho "2. #################" $boldgreen
cecho "3. #################" $boldyellow
cecho "4. #################" $boldblue
cecho "5. #################" $boldmagenta
cecho "6. #################" $boldcyan

cecho "启动成功" $c_notify 
cecho "启动失败" $c_error

输出效果:

通用shell函数库

 

相关文章:

  • 2022-03-05
  • 2021-09-15
  • 2021-12-26
  • 2022-12-23
  • 2021-07-17
  • 2021-12-25
猜你喜欢
  • 2021-09-26
  • 2021-12-05
  • 2021-11-03
  • 2022-12-23
  • 2022-01-15
  • 2021-12-25
相关资源
相似解决方案