On Wed, May 12, 2010 at 06:27:43AM -0500, Peng Yu wrote:
> x=10
> for i in {1..$x}; do echo $i; done
That won't work because of the way bash does its parsing. Brace expansion
is done before parameter (variable) expansion. Since the brace-expansion
part doesn't see 1..10 it can't generate a list
On 05/12/2010 01:27 PM, Peng Yu wrote:
x=10
for i in {1..$x}; do echo $i; done
The above code give me
{1..10}
, rather than printing numbers from 1 to 10.
I'm wondering how to use variable in a range?
This works for me;
x=10; for i in $(eval echo {1..$x}); do echo $i; done
But is not so
x=10
for i in {1..$x}; do echo $i; done
The above code give me
{1..10}
, rather than printing numbers from 1 to 10.
I'm wondering how to use variable in a range?
--
Regards,
Peng