-
UYOU
#!/bin/bashecho "hello!"T=$(date +%H)if [ "$T" -lt "12" ];thenecho "Good moring!"elif [ "$T" -lt "18" ];thenecho "Good afternoon!"elseecho "Good evening!"fiexit 0
-
精慕HU
#!/bin/shhour=`date +%H`if [ $hour -lt 12 ] && [ $hour -gt 0 ]thenecho "goodmorning"fiif [ $hour -lt 18 ] && [ $hour -gt 12 ]thenecho "goodafternoon"fiif [ $hour -gt 18 ]thenecho "goodevening"fi
-
慕斯709654
用date命令先取得当前的时间(仅取小时数) : date '+%H' #按24小时制取hour (00..23)然后与12进行比较,判断是不是12点之前参考脚本代码:12345678#!/usr/bashhh=`date '+%H'`if [ $hh -gt 12 ]then echo "$hh behind 12"else echo "$hh in front of 12"fi