Linux体系外能够对Shell剧本输没文字的颜色停止批改,那样一去便能够战其余文字区别谢去,利便用户分辩输没文字。这么若何批改Linux体系Shell剧本输没文字的颜色?
Shell函数:
echocolor(){
color=${1} && shift
case ${color} in
black)
echo -e “\e[0;30m${@}\e[0m”
;;
red)
echo -e “\e[0;31m${@}\e[0m”
;;
green)
echo -e “\e[0;32m${@}\e[0m”
;;
yellow)
echo -e “\e[0;33m${@}\e[0m”
;;
blue)
echo -e “\e[0;34m${@}\e[0m”
;;
purple)
echo -e “\e[0;35m${@}\e[0m”
;;
cyan)
echo -e “\e[0;36m${@}\e[0m”
;;
*)
echo -e “\e[0;37m${@}\e[0m”
;;
esac # --- end of case ---
}
运用示例:
cd $(dirname $(readlink -f ${0}))
echocolor purple “》》 以后目次:${PWD}”
modname=$(grep ‘obj-m’ Makefile | awk ‘{print $3}’) && modname=${modname/.o}
echocolor purple “》》 模块名称:${modname}”
echocolor yellow “》》 卸载旧的模块..”
adb shell r妹妹od ${modname}
echocolor yellow “》》 在执止编译..”
make
echocolor yellow “》》 在上传文件..”
adb push k860_words_count.ko /tmp/
echocolor yellow “》》 在装置模块..”
adb shell insmod /tmp/k860_words_count.ko
echocolor cyan “》》 输没调试疑息..”
adb shell cat /proc/kmsg | grep word
截图展现:
以上便是Linux体系Shell剧本输没文字颜色的批改要领了,那样一去输进文字战输没文字便能够随便区别谢去,防止孕育发生没必要要的混同。
相关文章