linux bash colorful log. 发表于 2018-06-19 | 分类于 linux | 阅读次数 | 1234567891011121314151617181920212223242526272829303132333435363738394041#!/bin/bash# Check for rootif [[ "$(id -u)" == "0" ]]then echo "$fail Do not run this script as root." exit 1fidisableColor=""if [[ $disableColor == "" ]] || [[ $disableColor == false ]]then fail="[$(tput setaf 1) FAIL $(tput sgr0)]" ok="[$(tput setaf 2) OK $(tput sgr0)]" running="[$(tput setaf 3) ** $(tput sgr0)]" notice="[$(tput setaf 3)NOTICE$(tput sgr0)]" warn="[$(tput setaf 3) WARN $(tput sgr0)]" info="[$(tput setaf 6) INFO $(tput sgr0)]" finish="[$(tput setaf 4) DONE $(tput sgr0)]"elif [[ $disableColor == true ]]then fail="[ FAIL ]" ok="[ OK ]" running="[ ** ]" notice="[NOTICE]" warn="[ WARN ]" info="[ INFO ]" finish="[ DONE ]"else echo "Unknown disableColor setting." exit 1fiecho "$fail this is fail."echo "$ok this is OK."echo "$running this is running."echo "$notice this is notice."echo "$warn this is warn."echo "$info this is info."echo "$finish this is finish." Donate WeChat Pay Alipay