加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 对于base来说,值太大了(错误标记是“0925”)

发布时间:2020-12-15 18:41:51 所属栏目:安全 来源:网络整理
导读:我的bash脚本中有以下逻辑: #!/bin/bashlocal_time=$(date +%H%M)if (( ( local_time 1430 local_time 2230 ) || ( local_time 0300 local_time 0430 ) )); then # do somethingfi 每一次,我得到标题中指定的错误(08xx以上的任何时候似乎触发错误). 关于如
我的bash脚本中有以下逻辑:
#!/bin/bash
local_time=$(date +%H%M)

if (( ( local_time > 1430  && local_time < 2230 ) || ( local_time > 0300 && local_time < 0430 ) )); then
 # do something
fi

每一次,我得到标题中指定的错误(08xx以上的任何时候似乎触发错误).

关于如何解决这个问题的任何建议?

我在Ubuntu 10.04 LTS上运行

[编辑]

我修改了SiegeX建议的脚本,现在我收到错误:[:10#0910:预期的整数表达式.

任何帮助?

bash将您的数字视为八进制,因为前导零

从男子bash

Constants with a leading 0 are
interpreted as octal numbers. A
leading 0x or 0X denotes hexadecimal.
Otherwise,numbers take the form [base#]n,where base is a decimal
number between 2 and 64 represent-
ing the arithmetic base,and n is a number in that base. If base# is
omitted,then base 10 is used.

要修复它,请指定base-10前缀

#!/bin/bash
local_time="10#$(date +%H%M)"

if (( ( local_time > 1430  && local_time < 2230 ) || ( local_time > 0300 && local_time < 0430 ) )); then
 # do something
fi

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读