linux shell编程中怎么判断时间相等
4 回答

慕斯709654
TA贡献1840条经验 获得超5个赞
用date命令先取得当前的时间(仅取小时数) : date '+%H' #按24小时制取hour (00..23)
然后与12进行比较,判断是不是12点之前
参考脚本代码:
12345678 | #!/usr/bash hh=` date '+%H' ` if [ $hh -gt 12 ] then echo "$hh behind 12" else echo "$hh in front of 12" fi |
添加回答
举报
0/150
提交
取消