I am trying to enumerate a range of integers using a variable but having some trouble. When I type
echo {1..5}
I get
1 2 3 4 5
However, when I type a variable, I am unable to get the enumeration. For example
$ num=5
$ echo {1..$num}
{1..5}
I am stumped as to why the result is not the same. I have tried using quotes and that has not helped either. Can someone help or explain?
eval
, but there are probably cleaner solutions. – jasonwryan Apr 23 '15 at 03:27ksh
. – Janis Apr 23 '15 at 03:57eval
way:eval echo \{1..$num\}
– Peter.O Apr 23 '15 at 07:24