| for <variable> in <items>; do <commands>; done |
| The for command is used to loop over a list of values and execute a series of |
| commands for each of these. |
| The counter variable of the loop is a shell variable. Please, keep in mind that |
| an environment variable takes precedence over a shell variable of the same name. |
| name of the counter variable |
| space separated item list |
| => for c in 1 2 3; do echo item ${c}; done |
| => for c in 1 2 3; do echo item ${c}; done |
| The first line ensures that there is no environment variable *c*. Hence in the |
| first loop the shell variable *c* is printed. |
| After defining an environment variable of name *c* it takes precedence over the |
| shell variable and the environment variable is printed. |
| The return value $? after the done statement is the return value of the last |
| statement executed in the loop. |
| => for i in true false; do ${i}; done; echo $? |
| => for i in false true; do ${i}; done; echo $? |