Let us see how to use for loop in shell scripting
Say we want to print "n" numbers.
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done
But, if we need to print 50 numbers, then it becomes a pain if we use the above method. So a simpler method is
for i in $(seq 50)
do
echo $i
done
'seq' is part of the GNU "coreutils" package
$ which seq
/usr/bin/seq
$ rpm -qf /usr/bin/seq
coreutils-5.97-23.el5
No comments:
Post a Comment