This is a multipart blog article series where I am going to explain the concepts of shell scripting and how to write a shell script in Linux, UNIX or Mac based systems. You can also follow this tutorial blog using windows but for that you have to install a bash from.
In this article we will learn about while loop. How to use while loop and what are it’s functionalities.
- The syntax of while loop
while [condition] do command1 command2 command3 done
- If we want to increment the value of the variable we can do that in this way
n=$(( n+1 ))or
(( n++ ))or
(( ++n ))
- First the condition we be checked in the while loop. If the condition is true than the part written after do will be executed.
- It will execute till the condition becomes false.
- And at last
donemeans that while loop has ended.
So this was about basic of while loop. Hope you liked it and learned something new form it.
If you have any doubt, question, quires related to this topic or just want to share something with me, than please feel free to contact me.