bash cp:目标不是目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36567083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cp: target is not a directory
提问by Archeg
I have a bash script with this line:
我有一个带有这一行的 bash 脚本:
cp -R /usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION/* /app/.apt/usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION
Full script: https://github.com/virtualstaticvoid/heroku-buildpack-r/blob/cedar-14/bin/compile
完整脚本:https: //github.com/virtualstaticvoid/heroku-buildpack-r/blob/cedar-14/bin/compile
Unfortunately it fails with cp: target ‘/app/.apt/usr/lib/gcc/x86_64-linux-gnu/4.8' is not a directory
不幸的是它失败了 cp: target ‘/app/.apt/usr/lib/gcc/x86_64-linux-gnu/4.8' is not a directory
Any tips what could be wrong? Unfortunately I do not have much experience with bash.
任何提示可能是错误的?不幸的是,我对 bash 没有太多经验。
Previously this script was running alone and it was working. Now I had to add some apt-get install
before it, and it started to fail so I am trying to fix it.
以前这个脚本是单独运行的,并且可以正常工作。现在我不得不apt-get install
在它之前添加一些,它开始失败,所以我试图修复它。
回答by Joda
There is no directory with the name 4.8...Thats your problem :)
没有名称为 4.8 的目录......那是你的问题:)
Run this before your cp command:
在你的 cp 命令之前运行这个:
mkdir -p /app/.apt/usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION
It creates all directories in the given path!
它会在给定路径中创建所有目录!
回答by Drako
This should work, add /
at the end of cp
command to make it clear for it that its dir:
这应该有效,/
在cp
命令末尾添加以明确其目录:
mkdir -p /app/.apt
cp -R $BUILD_DIR/.apt/* /app/.apt/