I am new to the group so please apologize for any mistake or badly formulated question. Here's my problem. I have a few arrays of variables. I want to simultaneously start different jobs with all possible combinations (e.g. different tasks). What I don't know how to do, is to sequentially access all possible combination of variables.
Here's a test bash script which only prints out the set of variables at each iteration. This does not look good to me as it prints much more than I expected. As I have 3 arrays of 2,3 and 4 variables, I'd need a total of 2 * 3 * 4 = 24 tasks. Can someone explain me what I am doing wrong or if there's a better yet cleaner way of doing it?
Here's a little example:
#!/bin/bash
#$ -N combi_test
#$ -t 1-24
ACQ=('ei')
VAR=('sh' 'rbf')
TRAIN=(1000 2000 3000)
ANGLES=(10 20 30 40)
for i in "${!ANGLES[@]}"; do
for j in "${!VAR[@]}"; do
for k in "${!TRAIN[@]}"; do
echo "IS_${ACQ}tr${TRAIN[k]}${ANGLES[i]}_${VAR[j]}.h5"
done
done
done
Thanks a lot in advance!
ANGLE
is notANGLES
. – Kamil Maciorowski May 05 '21 at 08:41for angle in "${ANGLES[@]}"; do
etc. (i.e., without the!
) and then use${angle}
and not${ANGLES[i]}
. Which ever feels better, of course. – ilkkachu May 05 '21 at 09:04