The “echo” below is failing and I cannot figure out why. I am simply trying to echo all of the array members in my loop.
#!/bin/bash
foo=bar1,bar2
for i in ${foo//,/" "}
do
declare -a ${i}='(null null null null)'
echo ${i[*]}
done
Thanks for any help!
Try
eval "echo \${$i[*]}"Why are you doing it this way? There is probably an easier and more direct way to do whatever your ultimate goal is. If you describe it, perhaps we can help you avoid the unnecessary complication.