Bash: how do I write an infinite loop?
Hi:
I want to do a Bash script that does only one thing: to execute program foo for ever and ever. I know I can use 'while' and 'until'. In a pseudo code of mine it'd be Code:
while TRUE |
|
Hi,
Something like this? Code:
#!/bin/bash |
Any of the bash looping facilities described here (except the first form of for) can be used to construct an infinite loop.
|
Yet another way:
Code:
while (:) ; do |
Most kind of you, Nylex for having replied to my post. Something funny happened with the script.
Code:
bash-3.1# cat u03.sh Code:
bash-3.1# cat u04.sh I extend my thanks to both druuna and catkin. |
goldenbarb has made me see why u03.sh got an error. I wrote 'while [ 1 ] do' while I should have written 'while [ 1 ]; do' or
while do That is to say: 'while' is a "sentence" and 'do' is another one. Either I write sentences in different lines or I separate them by ';' (semicolon). But Nylex's 'while [ 1 ]' construct intrigues me most. Both the use of square brackets (a complicated matter, I know) and the meaning of '1' in that construct. I suspect I could have written (pseudo code) repeat ... until [ 0 ] with the same result. |
Quote:
|
Notes:
|
Thanks to you all, guys, and forgive this way of learning bash.
|
All times are GMT -5. The time now is 11:47 PM. |