I try to make a pseudo array in bash
frame1=(one two three)
frame2=(one two three)
frame3=(one two three)
echo ${frame2[2]}
works but
for ((fr=1; fr<=$records; fr++))
do
frame$fr=(one two three)
done
doesn't work. How to make a pseudo array like that in bash ?
[edit] if I try to use the variable in the inside loop it doesn't work
for ((fr=0; fr<=$records; fr++))
do
declare -a "frame$fr=(one two three)"
done
for ((fr=0; fr<=$records; fr++))
do
for ((lv=0; lv<=$fields; lv++))
do
#echo ${frame$fr[2]}
echo ${frame6[$lv]}
done
done
the above works but the line that is commented out does not work it says
line 16: ${frame$fr[2]}: bad substitution
name=frame$fr[$lv]; echo "${!name}"will do.