bash loops

Updated: 14 December 2025

until loop

Similar to a while loop, except that the loop executes until the test-command executes successfully. As long as this command fails, the loop continues.

until test-command; do
    consequent-commands;
done

for loop

my_array=("apple" "banana" "orange" "grape")

for element in "${my_array[@]}"; do
    echo "Current element: $element"
done

Alternatively

for run in {11..15}; do
  echo 'it works?'
done

Leave a comment