我正在尝试使用Shell脚本复制所有文件和子目录。问题是某些文件夹名称中有空格。
cp -r "//shrdata/Legal/test location/test folder/*" "//shrdata/Legal/open access/"
我收到的错误是“系统找不到指定的文件”
尝试:
cp -r "/shrdata/Legal/test location/test folder"/* "/shrdata/Legal/open access/"
为了*
使其正常工作,它必须在引号之外。
假设我们有test folder
两个文件:
$ ls -1 test\ folder/
file1
file2
现在,让我们尝试*
用引号引起来:
$ echo "test folder/*"
test folder/*
由于的*
名称用引号引起来,因此它不会扩展为文件名列表。相反,它仅被视为文字字符。因此,如果我们尝试以这种方式复制文件,则会得到一个文件未找到的错误,因为没有文件被命名为*
:
$ cp "test folder/*" target
cp: cannot stat ‘test folder/*’: No such file or directory
如果我们将*
引号放在引号之外,则将执行路径名扩展:
$ echo "test folder"/*
test folder/file1 test folder/file2
这意味着,当与一起使用时,该表格将可以正常使用cp
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句