I'm trying to list an array of directory names using a while loop in a bash script.
The loop code is the following (where $len is the length of $folderArray):
i=0
while [ $i -lt $len ]; do
echo "$i: ${folderArray[$i]}"
let i++
done
However, my output is displayed as follows:
0: folder1
folder2
folder3
etc.
Why is the "1:" and "2:" not displayed for folder2 and folder3?
I read about using process substitution to solve this but I'm not sure how that would help here.