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

bash中的整数比较

发布时间:2020-12-15 22:23:36 所属栏目:安全 来源:网络整理
导读:我需要实现类似的东西: if [ $i -ne $hosts_count - 1] ; then cmd="$cmd;"fi 但我明白了 ./installer.sh: line 124: [: missing `]’ 我做错了什么? 解决方法 命令[无法在其测试中处理算术.将其更改为: if [ $i -ne $((hosts_count-1)) ]; then 编辑:@c
我需要实现类似的东西:

if [ $i -ne $hosts_count - 1] ; then
    cmd="$cmd;"
fi

但我明白了

./installer.sh: line 124: [: missing
`]’

我做错了什么?

解决方法

命令[无法在其测试中处理算术.将其更改为:

if [ $i -ne $((hosts_count-1)) ]; then

编辑:@cebewee所写的也是如此;你必须在结束前放一个空格].但是,这样做会导致另一个错误:额外的参数’ – ‘

(编辑:李大同)

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

    推荐文章
      热点阅读