Linux系统Shell脚本输出文字的颜色如何修改?
时间:2022-07-30 00:59:51
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 rmmod ${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脚本输出文字的颜色如何修改?](https://img.aspxhome.com/file/2023/3/a294232_0.jpg)
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
7月29日微软Windows 10发布详细计划曝光 全球狂欢
![](https://img.aspxhome.com/file/2023/28/a249130_0s.jpg)
Win11系统网卡驱动程序异常怎么修复?
![](https://img.aspxhome.com/file/2023/27/a234567_0s.jpg)
如何批量删除excel空白行?
![](https://img.aspxhome.com/file/2023/5/42825_0s.jpg)
Win7系统winsxs文件夹怎么瘦身?
![](https://img.aspxhome.com/file/2023/27/a231019_0s.jpg)
如何用excel打立方米的方法
4个与excel列操作相关的excel小技巧
Win11如何创建新用户?Win11创建新用户的方法
![](https://img.aspxhome.com/file/2023/27/a236440_0s.jpg)
Win10 Mobile预览版15047更新修复改进内容大全
![](https://img.aspxhome.com/file/2023/28/a242474_0s.jpg)
Win10系统Edge浏览器下载不了文件怎么办?
![](https://img.aspxhome.com/file/2023/25/a216947_0s.png)
win11不能玩植物大战僵尸怎么办?两种方法教你快速解决!
![](https://img.aspxhome.com/file/2023/30/a265745_0s.jpg)
Excel怎么利用VBA事先圆形沿直线移动的效果?
![](https://img.aspxhome.com/file/2023/9/40269_0s.jpg)
Win10电脑输入法图标不见了问题的解决方法
![](https://img.aspxhome.com/file/2023/28/a244559_0s.jpg)
wmi provider host占用cpu过高怎么办?wmi provider host占用cpu过高解决方法
![](https://img.aspxhome.com/file/2023/28/a239960_0s.jpg)
win10开始菜单全屏怎么调回去
![](https://img.aspxhome.com/file/2023/2/a287327_0s.png)
在Excel2010中设置图片属性(图片的颜色、对比度和亮度)
![](https://img.aspxhome.com/file/2023/3/42983_0s.jpg)
wps文字zm设置全屏显示图文教程
2种方法快速把word隐藏起来
![](https://img.aspxhome.com/file/2023/6/29336_0s.gif)
Win10 RS1预览版11103系统ISO英文版镜像下载
![](https://img.aspxhome.com/file/2023/28/a245781_0s.jpg)
Win11如何启用.NET Framework 3.5?
![](https://img.aspxhome.com/file/2023/30/a266946_0s.jpg)
excel自动保存文档的设置教程
![](https://img.aspxhome.com/file/2023/6/a154816_0s.jpg)