DEV Community

Cover image for While Loop | Shell Scripting
Rahul Mishra
Rahul Mishra

Posted on • Originally published at programmingport.hashnode.dev

While Loop | Shell Scripting

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
Enter fullscreen mode Exit fullscreen mode
  • 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 done means that while loop has ended.

Reference code file for this article

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.

πŸ“± Contact Me

Twitter
LinkedIn
Telegram
Instagram

πŸ“§ Write a mail

rahulmishra102000@gmail.com

πŸš€ Other links

GitHub
HackerRank

Top comments (0)