How is divine loop constructed.
We can see that the construct tests for their condition at the top of a loop and it keeps looping.
As long as that condition is true that means as long as the exit status of condition returns zero.
Usually we are using dialup in cases it's the number of Roop repetitions is not known beforehand.
Now we can see an example of a vial which is really stupid but easy to explain in that condition.
We are asking if a name variable is different from saying stop.
If yes then the existence of those test square brackets of that condition is zero.
That means that the script will execute commands between do and damn keyboards.
So it will ask you for your name and assign to a variable name and then the loop is done and we are
starting from the beginning.
We didn't condition is your name different from stop.
If yes continue it.
Body of vital.
So you will be looping till you enter stop as if we have C-style for you.
We also have C-style a while loop.
Here we are of writing condition into double parentheses and vote is important to mention inside the
double parentheses.
You cannot use dollar sign symbol using variable.
It is similar.
As for command a lot.
In the example of the C condition variable A is less than how they meant create file an income and value
of variable a so this code vote create nine files for us.
If it out to that condition equal sign that means if a variable A is less or equal to limit then the
code would create 10 files.
One of the most common usage of a WHILE loop is for reading files.
The structure is following.
We are starting to violate followed by variable which represents one line from the file between do and
keyboard.
We specify what we want to do with deadline and now what is most important After down damn keyboard.
We need to specify what file will be used as a source for standart input of a while loop.
So basically we are redirecting file into Vinal loop standart input.
We can also read the file line by line using another method or supply file as a standard input to while
loop using pipe.
If you want to write to screen line by line we would do that in the following way.
So we have discussed already.
So let's write some script to see it in action.