I am trying to get the user input a first time with read and get the input into the n2 variable, and then when the loop restarts ask the same read question but this time store the answer in the variable n3 and have the n# variable increment every time the loop restarts.
function addition(){
read -ep 'How many numbers in the equation?: ' amount
if [ $amount -ge 2 ]
then
read -ep 'First number of the addition?: ' n1
until [ $count = $amount ]
do
number=n$((inc++))
read -ep 'Next number for the addition?: ' n2
done
else
echo "Invalid amount. Must be at minimum 2"
fi
}
C, the array size ofbashis virtually limitless, although there may be some eventual limitation depending on the hardware. You don't even have to enter the maximum size of the array. The array automatically grows each time you append new elements. If you are interested in the solution using an array, I'll post one.