Bash to Basics: The For Loop

February 14, 2010 by · 2 Comments
Filed under: bash, HowTo, linux, Ubuntu 

Previously I've shown how to use the bash while loop in a bash script. Today I'm going to show how to use another type of do loop in bash: the for loop.

The for loop is a little different from the other looping structures in bash. The other loop structures work by evaluating whether an expression is true or false. The for loop works on lists of values. As long as there are items left in the list, the for loop will execute.

Here's a basic example. Read more