Posted By

miceno on 01/09/11


Tagged

loop


Versions (?)

Bash for loop


 / Published in: Bash
 

  1. for VARIABLE in 1 2 3 4 5 .. N
  2. do
  3. command1
  4. command2
  5. commandN
  6. done
  7.  
  8.  
  9. ### For within a range, but only when the limits are constants
  10.  
  11. #!/bin/bash
  12. for i in {1..5}
  13. do
  14. echo "Welcome $i times"
  15. done
  16.  
  17. ###
  18.  
  19. ### A traditional numeric loop
  20.  
  21. #!/bin/bash
  22. limit=5
  23. for (( c=1; c<=$limit; c++ ))
  24. do
  25. echo "Welcome $c times..."
  26. done

Report this snippet  

You need to login to post a comment.