Linux While Loop: How to Write and Use
In Linux, a while loop can be written in the following way:
#!/bin/bash
count=0
while [ $count -lt 5 ]
do
echo "Count is: $count"
((count++))
done
In the above example, the while loop continues to execute as long as the count is less than 5. Inside the loop, the current count value will be printed and the count will be incremented by 1. The loop will end when the count reaches 5.