For Loops

Create For Loop

In plain English: For each name in Lucien, Maurice, Renald, Johnson, and Alfred, print the name.

for name in Lucien Maurice Renald Johnson Alfred; do
    echo $name
done
Lucien
Maurice
Renald
Johnson
Alfred

Create C Style For Loop

Alternatively, we can use a style of for loop seen in the programming language C.

In plain English: Starting with i being 0, (i=0), as long as i is less than 10 (i<10), keep returning i, adding one to i (i=i+1) at the end of each loop.

for (( i=0; i<10; i=i+1 )); do
        echo $i
done

0
1
2
3
4
5
6
7
8
9