如何在脚本中触发大括号扩展?

时间:2011-08-16 16:06:48

标签: bash shell zsh brace-expansion

我正在编写一个需要使用shell的大括号扩展的脚本,但我没有尝试过任何工作。对于(一个人为的)实例,假设我有一个包含字符串

的变量
thing{01..02}

我(显然)希望将其扩展为

thing01 thing02  

从脚本内部,我该怎么做?

(对于任何认为这是this other question的副本的人,请仔细阅读。这个问题是关于shell的工作,而不是shell脚本,并且不需要扩展任意表达式的能力。)

2 个答案:

答案 0 :(得分:2)

$ echo thing{01,02}

thing01 thing02

答案 1 :(得分:2)

确保使用set -o braceexpand启用了braceexpand。