Bash For Loop

A for loop is a control flow statement that specifies iteration, allowing the statements within the loop to be executed repeatedly.

Example For Loop

for i in $( ls ); do
    echo item: $i
done

for i in `seq 1 10`; do
    echo item: $i
done

One Line For Loop

for i in $( ls ); do echo item: $i; done

for i in `seq 1 10`; do echo item: $i; done

C-style For Loop

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

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