Unix Date命令使用

时间:2014-04-04 17:25:39

标签: shell date unix datetime unix-timestamp

我很难解决然后解决方案帮助

T=`date + %k`
if [ $t –ge 0 –a $t –le 12 ];
then
    echo “Good Morning”
elif[ $t –ge 12 –a $t –le 14 ];
then
    echo “Good Afternoon”
elif[ $t –ge 14 –a $t –le 18 ];
then
    echo “Good Evening"
else
    echo “Good night”
fi

输出:[:日期意外操作员

1 个答案:

答案 0 :(得分:0)

t=`date +%k`
if [ $t -ge 0 -a $t -le 12 ];
then
  echo "Good Morning"
elif [ $t -ge 12 -a $t -le 14 ];
then
  echo "Good Afternoon"
elif [ $t -ge 14 -a $t -le 18 ];
then
  echo "Good Evening"
else
  echo "Goodnight"
fi