September 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

September 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

korn shell (ksh) – for loop

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>