I'm trying to use brace expansion on a string, but I can't seem to get it working with variable substitution:
Code:
$ cat script.sh
#!/bin/bash
echo {1,2,3} # 1.
VAR=1,2,3
echo {$VAR} # 2.
Code:
$ sh script.sh
1 2 3
{1,2,3}
I've searched google, tldp.org and these forums and I can't seem to find an example of how this would work. I want #2 to work like #1. Any suggestions?
**Edit: I forgot to add, the values in VAR are not sequential and can have multiple digits. For example, VAR=13,17,10.
**Edit2:
http://tldp.org/LDP/abs/html/bashver3.html#BRACEEXPREF3
The bottom line of code in the first gray block of code shows that you cannot use variables in such an expansion:
Code:
#!/bin/bash
a=1
b=5
echo {$a..$b}
But I'm looking for pasting the complete contents of a variable into these braces, not some portion of it...
Thanks,
Alex