I wanted to make my shell script wait infinitely and thought the below code would do it.
#!/bin/bash
while true
do
done
However, the above script reports syntax error.
./Infinite_Loop.sh: line 4: syntax error near unexpected token `done'
./Infinite_Loop.sh: line 4: `done'
Unlike programming languages, why does shell script expect at least one statement in loops?
Another option is just to set a NOP(no op) which is basically, do nothing.
In bash, the equivalent for a NOP is :
.
while true; do
:
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With