为什么 foo{bar, baz} 不扩展为“foobar”和“foobaz”?

问题描述 投票:0回答:1

我的目录中有两个文件:

com.my.arsys.core.js
com.my.arsys.core-libs.js

现在我想使用通配模式(大括号)来匹配这些并将它们复制到

a
文件夹,因此我运行以下命令:

cp com.my.arsys.{core, core-libs}.js a

但是我收到以下错误:

cp: cannot stat 'core,': No such file or directory
cp: cannot stat 'core-libs,': No such file or directory

我认为问题出在语法上。接下来我可以尝试什么?

shell unix
1个回答
2
投票

您有多余的空白,请尝试:

cp com.my.arsys.{core,core-libs}.js a

来自 bash man 关于 Brace Expansion

格式正确的大括号扩展必须包含不带引号的左大括号和右大括号,以及至少一个不带引号的逗号或有效的序列表达式。 任何错误形成的大括号扩展都保持不变。

© www.soinside.com 2019 - 2024. All rights reserved.