Until loop

For completeness, we have included the until loop. It is not used very often and is almost the same as a do while loop. Notice that its condition and operation is consistent with incrementing a counter until a value is reached:

#!/bin/bashCTR=1until [ ${CTR} -gt 9 ]do    echo "CTR var: ${CTR}"    ((CTR++)) # Increment the CTR variable by 1doneecho "Finished"

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.