Shell Script To Accept a Number and a Word

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. What happens if a number and a string is given as command line arguments?

n=$1
word=$2

while [ $n -gt 0 ]; do
    echo $word
    n=`expr $n - 1`
done

See Also

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.