"08 :value too great for base" 的原因及解决办法

今天调试shell时候 突然出现一个问题,之前都没有发现过

08 :value too great for base

<pre name="code" class="plain" style="margin: 4px 0px; background-color: rgb(240, 240, 240);">if [ $(($(date "+%M")%5)) -eq $((0)) ];then
echo 111
fi

 

最后跟踪问题,发现在时间为 08分钟和 09分钟时,都会出现这种问题,查阅资料
Numbers starting with leading 0 are Octal numbers  (base 8) in many programming
languages including C, Perl and shell. Valid octal digits are 
0,1,2,3,4,5,6,7 so it barfs if it sees an 8 or a 9. You probably want
to work in straight numbers and make a leading 0 in your output
format with a sprintf("%02d") kind of formatting thing.
Anything starting with 0x or 0X is a hex number.

So the error message means exactly as it says- it's an error from
the let function complaining about the value being too big for the base.

Have fun,
Stuart.

原帖地址:http://www.google.com/search?client=safari&rls=zh-cn&q=value+too+great+for+base&ie=UTF-8&oe=UTF-8

解决方案,增加 10# 定义为十进制就ok了

<pre name="code" class="plain" style="margin: 4px 0px; background-color: rgb(240, 240, 240);">if [ $((10#$(date "+%M")%5)) -eq $((0)) ];then
echo 111
fi

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值