将今天的日期与未来日期进行比较会导致一元操作员错误

时间:2015-10-25 14:38:12

标签: linux bash shell unix

我正在尝试将未来的日期与今天的日期进行比较。如果今天的日期大于到期日,那么“日期已过期”'应该显示。使用以下代码,我收到以下错误:[: 1445783380: unary operator expected - 我不确定我在这里做错了什么.-有什么想法吗?

        expireDate='2025-10-25 16:17:51'
        #format the expireDate date so it can be compared
        expireLoadGen=$(date -d $expireDate +%s)

       if [ $(date +%s) -gt $expireLoadGen ] 
        then        
        echo "Date has Expired"
        else
        echo "Date has not Expired"
       fi

1 个答案:

答案 0 :(得分:1)

a
相关问题