语法错误:预期操作数(误差令牌&QUOT + QUOT;) [英] Syntax error: operand expected (error token is "+")

查看:300
本文介绍了语法错误:预期操作数(误差令牌&QUOT + QUOT;)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写在bash脚本,我得到这个错误:

I'm writing a script in bash and I get this error:

./P4.1: line 10: +: syntax error: operand expected (error token is "+")

这是我的code:

And this is my code:

#!/bin/bash
read string
echo $string >| temp
num1= cut -d" " -f1 temp
num2= cut -d" " -f2 temp
num3= cut -d" " -f3 temp
while [ $num1 -gt $num3 ]
do
        echo $num1
        num1=$[$num1+$num2]
done

什么是错的,我怎么解决?
谢谢你。

What's wrong and how do I fix it? Thanks.

推荐答案

ceving和托梅克的组合:

Combination of ceving and Tomek's:

#!/bin/bash
read num1 num2 num3
while [ $num1 -lt $num3 ]
do
    echo $num1
    num1=$((num1+num2))
done

这篇关于语法错误:预期操作数(误差令牌&QUOT + QUOT;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆