how to assign to a variable in Bash an array element such that the array is index itself by a variable (a most trivial thing in any language but seems special in bash?)
I tried many variants such as:
let temp1=list1[list1Index]
or
 temp1=${list1[$list1Index]}
none of them work obviously. No error but nothing is displayed by echo $temp1 What can I do?
here is the full code (with dummy names for paths):
#! /bin/bash
pathFrontalGray='/mnt/c/Users/dummyName/'
list1=('x' 'y' 'z' 'a' 'b' 'c')
prefix1='dummyName'
echo $pathFrontalGray
touch fileNamesGray.txt
ls $pathFrontalGray > fileNamesGray.txt
fileGray='fileNamesGray.txt'
list1Index=0
i=0
while IFS= read -r line
do
    let i=i+1
    echo $i
    #means if NOT divisibe by 9  -> if <expr evaluated to 0> -> equiv if false
    if (($i % 9));then
        let list1Index=list1Index+1
    fi
    temp1=$list1[$((list1Index))]
    echo $temp1
    #mv $pathFrontalGray$line $prefix1${list1[$list1Index]}
    # display $line or do somthing with $line
    #printf '%s\n' "$line"
done <"$fileGray"
