相关疑难解决方法(0)

我可以在没有 `eval` 的情况下在 {} 扩展中使用变量吗?

我可以在{}扩展中使用变量而不吸引eval吗?如果是这样,如何?

这不起作用:

$ touch 1.foo 1.bar
$ ls 1.{foo,bar}
1.bar  1.foo
$ extensions=foo,bar
$ ls 1.{$extensions}
ls: cannot access 1.{foo,bar}: No such file or directory
Run Code Online (Sandbox Code Playgroud)

它适用于eval

$ eval ls 1.{$extensions}
1.bar  1.foo
Run Code Online (Sandbox Code Playgroud)

bash wildcards brace-expansion variable-substitution

7
推荐指数
1
解决办法
1535
查看次数