value too great for base (error token is "08")

while (( 0<1 ))
do
   tsecond=$(date +%S)
   tt=$((tsecond%30))  


问题就出在取模运算(%)这了,原因如下:
引用:
Numbers starting with leading 0are Octal numbers  (base 8) in many programminglanguages 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 wantto work in straight numbers and make a leading 0 in your outputformat 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 fromthe let function complaining about the value being too big for the base.

Have fun,
Stuart.


下面是解决办法:
引用:
You can explicitly state the base of a number using base#number
Code:
if [ $((10#$item)) -eq 0 ] ; then
That will have trouble if the number starts with a minus sign.
The '-' needs to be in front of the base like -10#009 for -9.


你可能感兴趣的:(token,for,value,base,is,too,Great,(error,"08"))