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

user5647516 picture user5647516 · Dec 13, 2015 · Viewed 108.8k times · Source

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?

Answer

isapir picture isapir · Jul 9, 2018

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