What are the loop forms in Bash?
BeginnerConceptArrays, conditionals and loops
Answer
for host in web1 web2 web3; do ...; done # list
for f in /var/log/app/*.log; do ...; done # glob
for ((i = 1; i <= 5; i++)); do ...; done # C-style
while systemctl is-active --quiet app; do sleep 5; done # while condition succeeds
until curl -fsS localhost:8080/healthz; do sleep 2; done # until it succeeds
while IFS= read -r line; do ...; done < file # lines of a file
break exits the loop, continue skips to the next iteration; both accept a level number for nested loops (break 2).
More on Arrays, conditionals and loops
How do you declare, populate and iterate an indexed array?BeginnerWhat is the difference between `"${arr[@]}"` and `"${arr[*]}"`?IntermediateHow do associative arrays work and what are they good for in DevOps scripts?IntermediateHow do you read a command's output into an array correctly?IntermediateWhat is the difference between `[ ]`, `[[ ]]` and `(( ))`?BeginnerWhy does `[ $var = "prod" ]` fail when `var` is empty or contains spaces?Intermediate