When I try to copy cp -rf mydir/* .../mydir/.
I get next error:
cp: cannot stat 'mydir/*': No such file or directory
But there are files in this directory.
Please help me to find out reason of it.
If the shell cannot find anything to expand *
into, then it leaves it untouched. So if there are no files or directories in mydir
(except hidden/dot files/directories), then mydir/*
is passed as it is to cp
. And cp
cannot find any file called mydir/*
, as the error says.
For example:
$ ls /srv -l
total 0
$ ls /srv/*
ls: cannot access /srv/*: No such file or directory
Unless you're trying to exclude hidden files and folders you should simply do:
cp -r mydir ../
.../
did you mean../
? – terdon Oct 17 '14 at 12:22