I have the following script that works fine:
!/bin/bash
a=12
while [ $a -gt 10 ]
do
echo "$a"
a=$(($a-1))
done
echo "done"
If I add line "echo something" above "do", I expect to see a syntax error in that line. It seems that [ $a -gt 10 ]
is bypassed, and it becomes an infininte loop. How could that happen?
do-while
loops like in C, to check the condition after each iteration instead of before. – JoL Dec 5 '19 at 17:10