#!/bin/bash
# Normal for loop example
START=1
END=10
for ((i=$START; i<=$END; i++))
do
echo "i: $i"
done
# Implicit items
for VARIABLE in file1 file2 file3
do
command1 on $VARIABLE
command2
commandN
done
# With range {..}
for i in {1..10};
do
echo "i: $i"
done
# With ranges and incrementing by 2
for i in {1..10..2};
do
echo "i: $i"
done
# With a variable sequence
COUNT=10
for i in $(seq 1 $COUNT);
do
echo "i: $i"
done