The Linux Command Line Chapter 29 Flow Control: Looping With while / until Prepared by Dr. Reyes, New York City College of Technology
while Loop while – a command that evaluates the exit status of a list of commands, and executes the commands inside the loop as long as the exit status is zero. Stops otherwise. Syntax: while commands; do commands done
while Loop Example
Breaking Out Of A Loop break – A command that immediately terminates a loop, and makes a program control resume with the next statement following the loop. continue – A command that causes the remainder of the loop to be skipped, and program control resumes with the next iteration of the loop. These commands should seldom be used.
The until Command until - A command similar to the while, except that instead of exiting a loop when a nonzero exit status is encountered, it does the opposite. An until loop continues until it receives a zero exit status Syntax: until commands; do commands done
until Command Example