value too great for base (error token is "08")
2016-03-11 10:16
465 查看
shell 中,经常有定时任务, 这时候shell脚本中一般会对时间进行一些判断,或者相关逻辑的操作
这时候,如果你获取的小时或者分钟是08,09,如果要再对其进行运算符或者比较的话,就会报标题的错误。
原因:
shell 默认认为0开始是个八进制,而八进制不可能出现8,9,所以报错。
解决方法:
主动的显示指定10进制,例子(前人的,非常不错,直接引用)
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.
如果是个负数,需要在前面加”-“,如 -10#08
这时候,如果你获取的小时或者分钟是08,09,如果要再对其进行运算符或者比较的话,就会报标题的错误。
原因:
shell 默认认为0开始是个八进制,而八进制不可能出现8,9,所以报错。
解决方法:
主动的显示指定10进制,例子(前人的,非常不错,直接引用)
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.
如果是个负数,需要在前面加”-“,如 -10#08
相关文章推荐
- iOS学习之UINavigationController
- Android深入浅出系列之Bluetooth—蓝牙操作(一)
- Android深入浅出系列之Bluetooth—蓝牙操作(二)
- Qt Quick 事件处理之信号与槽
- IOS判断应用是否第一次打开&UIScrollView实现新应用第一打开欢迎介绍页面
- UIKit-UIDatePicker和UIPickerView
- UIKit-UIAlertView,UIActionSheet,…
- UIKit-UIView二维图形Affine几何变…
- UIKit-UIView常用设置
- UIKit-boundingRectWithSize计算多行UILabel的文字高度
- UITableView和NavigationBar的常用设置
- 用PhoneGap Build将写好的htm…
- 《iOS Human Interface Guidelines》——Collection View
- 转:蓝牙物理链路类型:SCO和ACL链路
- 【代码笔记】给UIImageView加上圆角效果
- 【代码笔记】给UIImageView加上圆角效果
- 扩展对EasyUI的校验规则
- STL之priority_queue
- xcodebuild命令行编译错误问题解决
- 给easyui datebox扩展一个清空按钮