值对于基数太大(错误令牌为"09") [英] Value too great for base (error token is "09")
本文介绍了值对于基数太大(错误令牌为"09")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行我的bash脚本的这一部分时出现错误
When running this part of my bash script am getting an error
脚本
value=0
for (( t=0; t <= 4; t++ ))
do
d1=${filedates[$t]}
d2=${filedates[$t+1]}
((diff_sec=d2-d1))
SEC=$diff_sec
compare=$((${SEC}/(60*60*24)))
value=$((value+compare))
done
输出
jad.sh: line 28: ((: 10#2014-01-09: value too great for base (error token is "09")
jad.sh: line 30: /(60*60*24): syntax error: operand expected (error token is "/(60*60*24)")
d1和d2是采用2014-01-09和2014-01-10格式的日期
d1 and d2 are dates in that form 2014-01-09 and 2014-01-10
请问有什么解决方法吗?
Any solution please?
推荐答案
在变量的前面加上字符串"10#".这迫使bash将它们视为十进制,即使前导零通常会使它们变为八进制.
Prepend the string "10#" to the front of your variables. That forces bash to treat them as decimal, even though the leading zero would normally make them octal.
这篇关于值对于基数太大(错误令牌为"09")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文