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?
You may use this:
num=5;
echo $(seq $num)
Gives:
1 2 3 4 5
Remark: $(...)
syntax is command substitution.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments