I am having trouble formatting nested for loops for long strings of input:
I am currently using the below nested for loops to name output files from a separate program that I have omitted:
#!/bin/bash
for hemi in lh rh
do
for measure in thickness area volume meancurv gauscurv foldind curvind
do
echo ${hemi}"--"${measure}
done
done
I would like to be able to format the loops like below to facilitate running multiple different loops with much longer array lists that may need to be modified. Only needing to modify the list in one place will greatly reduce the chance for errors/omissions etc:
#!/bin/bash
hemi=( lh rh )
measure=( thickness area volume meancurv gauscurv foldind curvind )
for((i=${hemi[${i}]};i<2;i++));do
for((j=${measure[${j}]};j<7;j++));do
echo ${hemi[${i}]}"--"${measure[${j}]}
done
done
This is the output I am getting and I am not able to figure out what I am doing wrong:
lh--thickness
lh--area
lh--volume
lh--meancurv
lh--gauscurv
lh--foldind
lh--curvind
./for_loop_testing.sh: line 7: ((: j=: syntax error: operand expected (error token is "=")