下面是shell脚本中提到的代码
SOURCE="/my/folder"
DESTINATION="/my/destination"
cp -r "$SOURCE/subdir/"* "$DESTINATION/another_sub/"
代码给我一个错误
/my/folder: no such a file or directory
这段代码有什么问题。我还检查了文件夹,如果我直接放在终端上,它可以工作,但使用 shell 脚本它不工作
最佳答案
/my/folder: no such a file or directory
此错误表明无法从根 /
中找到该文件夹。
尝试
SOURCE="./my/folder"
DESTINATION="./my/destination"
如果脚本在与文件夹相同的目录中运行。或者使用
SOURCE="~/my/folder"
DESTINATION="~/my/destination"
如果这些文件夹位于用户的主文件夹之外。
关于linux - 将文件从一个位置复制到另一位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57972554/