如何触发脚本中的括号扩展? [英] How can I trigger brace expansion inside a script?

查看:106
本文介绍了如何触发脚本中的括号扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,该脚本需要使用shell的大括号扩展名,但是我没有尝试过.对于(人为)实例,说我有一个包含字符串

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

thing{01..02}

我(显然)想将其扩展为

and I (obviously) want to expand it to

thing01 thing02  

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

from inside the script, how can I do that?

(对于任何认为这是其他问题的重复的人,请更仔细地阅读它们.这个问题是关于从shell而不是shell脚本工作的,并且不需要扩展任意表达式的能力.)

(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.)

推荐答案

$ echo thing{01,02}

thing01 thing02

这篇关于如何触发脚本中的括号扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆