How do I echo a sum of a variable and a number?

前端 未结 9 681
眼角桃花
眼角桃花 2020-12-30 05:03

I have a variable x=7 and I want to echo it plus one, like echo ($x+1) but I\'m getting:

bash: syntax error near unexpected

9条回答
  •  有刺的猬
    2020-12-30 05:32

    try echo $(($x + 1))

    I think that only works on some version of bash that is 3 or more..

    echo `expr $x + 1`
    

    would be another solution

提交回复
热议问题