I am new to shell scripting. I am trying to create an array of size n, where n is input by the user during the run time.
while [ $i -lt $n ]
do
echo For person $i enter the name?
read io
eval Name[$index]= $io
done
When I try to do this, the values are overwritten every time the loop gets the input from user.
For ex: if person 1 is - Tom,if person 2 is - John. Then when i try to print the names of all person at the end of the script, person 1 name is overwritten with person n th name.(which means, all names are stored in a single variable instead of an array).
Can someone tell me where am i going wrong?
$indexandeval. Simply replaceeval Name[$index]= $iowithName=("${Name[@]}" "$io").