linux - 将文件从一个位置复制到另一位置

标签 linux shell raspberry-pi

下面是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/

相关文章:

linux - Kinect + Linux 的用途是什么?

c - 如何将 fork() 移植到 Vxwork

linux - 在 linux 中使用 sed 或 awk 替换具有双斜杠的字符串

c++ - 安装和使用适用于 C++ 的 MQTT Paho 库

raspberry-pi - 使用 Raspbian Buster 在新的 RaspberryPi 4 上构建 Redis 失败

linux - 蓝牙错误 : Native Library bluecove_arm not available

android - 如何在Raspberry Pi和Android智能手机之间进行同步通信?

regex - 具有两个值的 Shell 脚本变量赋值(正则表达式)

linux - 在 Eclipse 中设置 bash 脚本

linux - 如何开发linux屏保