I am trying to write a ksh script to accept user amount of parameters. so far I have written the following but, when I run the script it gives me the "i" back instead of the parameter's value. can anyone please tell me what I'm doing wrong.
Thank you in advance:)
#!/bin/ksh
echo "How many Parameter would you like to accept?"
read num
for ((i=1;i<=num;i++))
do
echo ${!i}
done
I am trying to calculate the total of the parameters that is set by the user input and get the average of those parameters. That's why I need the values rather than the position numbers. It is just part of my coursework as a student.
Thank you Don Cragun, the direct approach is much better than creating a new variable.
PS. I would very much appreciate any links or book recommendation to understand ksh script.
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.
Please review the rules, which you agreed to when you registered, if you have not already done so.
More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.