x=1
while [ $x -le 50 ]
do
echo $x
$x=(($x + 1))
done
I have wrote the above code. What seems to be a easy task in many programming languages is giving this error for me.
solution.sh: line 5: syntax error near unexpected token `('
solution.sh: line 5: ` $x=(($x + 1))'
How to debug errors in bash. Is there any IDE?
bash -x scriptnameto debug.x=$(($x + 1)). But easy to useseqinstead all scriptseq 50echo {1..50}. And in$(())environment, the variables inside are automatically evaluated, which is why you don't need the$inside it again.((x++)). Also look up theletcommand.