I found this code
ls | while read line
array[ $i ]="$line"
(( i++ ))
from this post
However the code is not working for me. Anytime I try to echo one of the array entries it doesn't display anything.
Is this code to old to work? It doesn't seem that old.
I run the code in the terminal like this:
i=1; ls | while read line;do array[$i]="$line"; (( i++ )); done
And it doesn't work.
This line works:
ls | while read line;do echo "$line"; done
It lists all the stuff in the current directory I am in on separate lines.
I am thinking maybe just the array part of the code is wrong.