I have the following problem in a bash script. I'm trying to use a variable N
as the upper bound in a simple range, like
#!/bin/bash
N=10
for n in {1..$N};
do
echo $n
done;
However, instead of displaying each number in the loop, the code above literally displays {1..10}
. If I change $N
to its value, i.e. 10
, things work as expected. How can I overcome this and use the variable as the upper limit of the range?