Value too great for base (error token is “09”)

后端 未结 6 1671
我寻月下人不归
我寻月下人不归 2020-11-27 06:31

When running this part of my bash script am getting an error

Script

value=0
for (( t=0; t <= 4; t++ ))
do
d1=${filedates[$t]}
d2=${filedates[$t+1]         


        
6条回答
  •  我在风中等你
    2020-11-27 07:27

    d1 and d2 are dates in that form 2014-01-09 and 2014-01-10

    and then

    ((diff_sec=d2-d1))
    

    What do you expect to get? ((diffsec=2014-01-09-2014-01-10)) ??

    You need to convert the dates to seconds first:

    d1=$( date -d "${filedates[$t]}" +%s )
    d2=$( date -d "${filedates[$t+1]}" +%s )
    (( compare = (d2 - d1) / (60*60*24) ))
    (( value += compare ))
    

提交回复
热议问题