File: test.sh
Command: sh test.sh
Content of test.sh
x=1
while [ $x -le 5 ]
do
echo "Welcome $x times"
x=$(( $x + 1 ))
done
Error:
test.sh: line 6: syntax error near
unexpected token `done’test.sh: line 6: `done’
GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
It works when I run that code.
Make sure you’re running with bash not sh. The
$(( ))construct is relatively new.