bash 什么是 cp:在 Unix 中无法统计错误,尝试将内容从一个文件夹复制到另一个文件夹时出现此错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34254164/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:09:06  来源:igfitidea点击:

What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another

bashunixcommand-linecpmv

提问by user5647516

Hi I wanted to know why I am getting this error. I have this directory called mock, which inside has another 3 directories. I am trying to copy all the items from mock directory into the projweek directory using the below code.

嗨,我想知道为什么我会收到此错误。我有这个名为 mock 的目录,里面还有另外 3 个目录。我正在尝试使用以下代码将模拟目录中的所有项目复制到 projweek 目录中。

cp  /mock/* ~/projweek

But I get this error

但我收到这个错误

cp: cannot stat ‘mock/*': No such file or directory

any ideas as to why that is?

关于为什么会这样的任何想法?

回答by isapir

If your source directory is set in quotes, then make sure that the *is outside the quotes, i.e.

如果您的源目录设置在引号中,那么请确保在引号*之外,即

cp "source/"* dest

or

或者

cp "source"/* dest

回答by isapir

cp is used in unix/linux for copy

cp 在 unix/linux 中用于复制

cp /mock/* ~/projweekthis means copy from /mock folder all files to folder projweek that resides in root

cp /mock/* ~/projweek这意味着从 /mock 文件夹中将所有文件复制到位于 root 中的文件夹 projweek

This means cp: cannot stat ‘mock/*': No such file or directoryunable to copy all files from mock folder because file or directory not exists on relevant path

这意味着cp: cannot stat ‘mock/*': No such file or directory无法从模拟文件夹复制所有文件,因为相关路径上不存在文件或目录

回答by WesternGun

cannot stat= file/dir does not exist. Check the path first.

cannot stat= 文件/目录不存在。首先检查路径。

And, you say you want to copy /mockbut the error message says mock. Show the real code first.

而且,您说要复制,/mock但错误消息说mock。先展示真正的代码。

When I test in ubuntu, cp (GNU coreutils) 8.28, I have no problem with copying all files under a dir to another dir, when both paths are correct.

当我在 ubuntu 中测试cp (GNU coreutils) 8.28时,当两个路径都正确时,将一个目录下的所有文件复制到另一个目录没有问题。

root@DESKTOP-9NHNV2I:~# cp /root/temp/* /root
root@DESKTOP-9NHNV2I:~# ls
temp  test.txt  test2.txt  test3333.txt