I want to construct variable name N_foo and N_bar and use their values in the following:
#!/bin/bash
N_foo=2
N_bar=3
for i in { "foo" "bar" }
do
for j in { 1..$(`N_$i`) }
do
echo $j
done
done
I want to use the values of N_foo and N_bar in the two inner loops and print out 1, 2 and 1, 2, 3, respectively. What's the correct syntax?
{}from outer for and remove space next to the{}in inner loop.echo { 1..3 }does not produce what you want.