So I have something that looks like this:
a=1
declare -a array
cat ~file | while read line
do
array[$a]=$line
let a=$a+1
echo ${array[(($a - 1))]}
done
read n
m=$n
echo ${array[$m]}
When I echo the array in the loop, it works, but when I try to refer to it outside of the loop, it does not work. Can someone please tell me why? The second echo does not return the value of the array.