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

◇◆丶佛笑我妖孽 提交于 2020-05-12 11:06:29

问题


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.

cp  /mock/* ~/projweek

But I get this error

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

any ideas as to why that is?


回答1:


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



回答2:


cp is used in unix/linux for copy

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

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




回答3:


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

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

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.

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


来源:https://stackoverflow.com/questions/34254164/what-is-cp-cannot-stat-error-in-unix-i-get-this-error-when-trying-to-copy-thin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!