examples/shell/while_loop.sh

  1. count=5
  2.  
  3. while [ $count -lt 10 ]; do
  4. echo $count
  5. sleep 1
  6. count=$(($count + 1))
  7. done

examples/shell/while_loop_break.sh

  1. count=5
  2. while true; do
  3. echo $count
  4. sleep 1
  5. count=$(($count + 1))
  6. if [ $count -gt 9 ];
  7. then
  8. break
  9. fi
  10. done
  11.  

examples/shell/while_loop_continue.sh

  1. count=5
  2. while true; do
  3. echo $count
  4. sleep 1
  5. if [ $count -lt 9 ];
  6. then
  7. count=$(($count + 1))
  8. continue
  9. fi
  10. break
  11. done
  12.  
  13.