How to add the info from read into a list?
Hi, I'm trying to read the user's input and store them in a list using a while loop. I came up with the following code but it just adds a new input each time and deleting the previous input instead of storing them all. Also I'm using -1 to quit the program but current setup will insert the -1 into the list too which I want to avoid.
I'm new to linux. any guidance is appreciated. Tnks in advance. :)
Code:
#!/bin/bash
userInput=-99999
while [ $userInput -ne -1 ]
do
echo "Enter any number. Enter -1 to quit"
read userInput
myArray=($userInput)
echo $myArray
done