iconoclast iconoclast - 1 year ago 67
Bash Question

How can I trigger brace expansion inside a script?

I'm writing a script which needs to use the shell's brace expansion, but nothing I've tried works. For (a contrived) instance, say I have a variable containing the string


and I (obviously) want to expand it to

thing01 thing02

from inside the script, how can I do that?

(For anyone who assumes this is a duplicate of this other question, please read them more carefully. That question is regarding working from the shell, not a shell script, and doesn't require the ability to expand arbitrary expressions.)

Answer Source
$ echo thing{01,02}

thing01 thing02
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download