首页 > 其他 > 详细

脚本_根据计算机当前时间,返回问候语

时间:2019-07-05 20:13:48      阅读:116      评论:0      收藏:0      [点我收藏+]

#!bin/bash
#作者:liusingbon
#功能:根据计算机当前时间,返回问候语,可以将该脚本设置为开机启动
#00-12点为早晨,12-18 点为下午,18-24 点为晚上
#使用date命令获取时间后,if 判断时间的区间,确定问候语内容
tm=$(date +%H)
if [ $tm -le 12 ];then
msg="Good Morning $USER"
elif [ $tm -gt 12 -a $tm -le 18 ];then
msg="Good Afternoon $USER"
else
msg="Good Night $USER"
fi
echo -e "\033[34m$msg\033[0m"
echo "当前时间是:$(date +"%Y-%m-%d %H:%M:%S")"


脚本_根据计算机当前时间,返回问候语

原文:https://www.cnblogs.com/liusingbon/p/11140437.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!