Transferred from: http://blog.chinaunix.net/uid-23046336-id-3475462.html
Programs programmed under Linux apes know shell scripts, and even if you're not familiar with them, you should have heard them! What about the dead loop in the shell script?
For apes who are familiar with C, the simplest cycle of death should be written like this:
-------------------------------------------------------------------------
while (1)
{
Do something
}
------------------------------------------------------------------------
Or you can do it with a for statement and a do...while statement, not here!
But how do you write a dead loop in a shell script?
To the shell is not familiar with the ape man, believe that this problem must have baffled everyone, anyway this problem once baffled me ...
Google on the internet after a look at some information, I suddenly dawned! The original can be written like this:
------------------------------------------------------------------------
While ["1" = "1"]
Do
# do something
Done
------------------------------------------------------------------------
Or
------------------------------------------------------------------------
While test "1" = "1"
Do
# do something
Done
------------------------------------------------------------------------
Perhaps, you will think and C language a bit like, sure! But please note that this is a script!
See here you may know how to write a dead loop in the shell, but is this really the simplest cycle of death?
Not really! The simplest dead loop should be written like this, (note: I'm here to call it the simplest, and perhaps the simplest!) )
------------------------------------------------------------------------
While:
Do
# do something
Done
------------------------------------------------------------------------
See here, perhaps you will be very puzzled son, this is what thing, even suspicion I in "stride"-----"pull an egg", actually my step is small, absolutely can't pull the egg!
Yes, it is indeed a cycle of death, do not believe you can try! Note that "#" is the meaning of the comment line in the shell, except for this #!/bin/sh
There is ":" in the shell to represent an empty statement, is nothing to do! Equivalent to ";" In C!
All right, here we go!
Thanks for browsing!
"Simplest dead loop" "Turn" of shell script programming