I have an array that contains
line number 1
line number 2
line number 3
line number 4
line number 5
Then I ask for the user input:
read userInput
echo $userInput
And then I try to match the user input, which is a number to my array
for i in "${!array[@]}";do
if [["${array[$i]}"="$userInput"]]
then
echo "~"
echo " $i"
fi
done
But this doesn't work. The desire output is this:
4
line number 1
line number 2
line number 3
~line number 4
line number 5
Can anyone help me please?
if [[ "${array[$i]}" = "$userInput" ]]
– rudimeier Oct 12 '16 at 21:01