If you need to read a file line by line and perform some action with each line – then you should use a while read line construction in Bash, as this is the most proper way to do the necessary.. Here echo is being used as it's an easy way to illustrate what is going on. Shortest? (adsbygoogle = window.adsbygoogle || []).push({}); You can use : special command with while loop to tests or set an infinite loop or an endless loop. The case statement is used to match values against $choice variable and it will take appropriate action according to users choice. This for loop contains a number of variables in the list and will execute for each item in the list. In this tutorial, we will learn some of the ways to create an infinite while loop, with the help of example Python programs. No matter what, one is always going to be equals to one. The following example of while loop will run continuously until stopped forcefully using ctrl + c. while true do echo "Press CTRL+C to Exit" done Example 2: We can also use colon “:” in place of “true” with while loop for creating infinite loop in bash script. … : always returns true. It can be as simple as waiting for a variable to become equal to a specified number, or as complex as waiting for the output for another command to match the output we specified. The while loop is another popular and intuitive loop you can use in bash scripts. Termination condition is defined at the starting of the loop. It is recommended to go through Array Basics Shell Scripting | Set-1 Introduction Suppose you want to repeat a particular task so many times then it is a better to use loops.