Shell Scripting while loop
Linux scripting while loop is similar to C language while loop. There is a condition in while. And commands are executed till the condition is valid. Once condition becomes false, loop terminates.
Syntax of while loop is shown in the snapshot below,
We have shown the example of printing number in reverse order.
Output is displayed in the below snapshot,
while infinite loop:
Infinite loop is also called endless loop. It is made with while true (it means condition will always be true) or while : (it means an empty expression), where colon (:) is equivalent to no operation.
Look at the above snapshot, this script includes while truesyntax.
Look at the above snapshot, this script includes while: syntax.
Both of them display the same output.