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 token `$x+1'
How can I do that?
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 token `$x+1'
How can I do that?
From
man bash
:Just use the
expr
command:Try this way:
Try double parentheses:
try echo $(($x + 1))
I think that only works on some version of bash that is 3 or more..
would be another solution
We use
expr
for that: