Reading from a file
for line in $(cat /etc/passwd)
do
echo $line
done
Iterate for a range
for number in {1..10}
do
echo “Current number is $number”
done
Loop for values given
for planet in earth mars saturn jupiter
do
echo “The planet name is $planet”
done
Loop for variable containing multiple values
planets=”earth mars saturn jupiter pluto”
for planet in $planets
do
echo “The planet name is $planet”
done
Recent Comments