Sunday, 17 June 2012

Write a shell script to accept a number and a word as command line arguments and print the word the given number of times on each line


i=1
f=""
temp=$1" "
while [ $i -le $3 ]
do
f=$f$temp
i=`expr $i + 1`
done
i=1
while [ $i -le $2 ]
do
echo $f
i=`expr $i + 1`
done

No comments:

Post a Comment