I have the following bash script:
#!/bin/bash
upperlim=10
for i in {0..10}
do
echo $i
done
for i in {0..$upperlim}
do
echo $i
done
The first for
loop (without the variable upperlim
in the loop control) works fine, but the second for
loop (with the variable upperlim
in the loop control) does not. Is there any way that I can modify the second for
loop so that it works? Thanks for your time.
for i in {0..$((upperlim))}; do echo $i; done
does not work – Bonsi Scott Nov 10 '12 at 20:34