Answers for "exit loop bash"

0

exit loop bash

# [n] is an optional argument and must be greater than or equal to 1. 
# When [n] is provided, the n-th enclosing loop is exited. break 1 is equivalent to break.

break [n]

# an example
i=0

while [[ $i -lt 5 ]]
do
  echo "Number: $i"
  ((i++))
  if [[ $i -eq 2 ]]; then
    break
  fi
done

echo 'All Done!'
Posted by: Guest on June-21-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language