LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cp: cannot stat '*': No such file or directory (https://www.linuxquestions.org/questions/linux-newbie-8/cp-cannot-stat-%2A-no-such-file-or-directory-4175490656/)

Tachtory 01-09-2014 03:18 AM

cp: cannot stat '*': No such file or directory
 
Not sure what is causing this

I am trying to copy the contents of /etc/skel to a backup directory located in my home directory. Tried as root, same message.

Code:

root@darkstar /etc/skel # cp * /home/bjornb/backup/etc-skel/
cp: cannot stat '*': No such file or directory

I tried searching and found many results but I couldn't find a common cause. I did reboot this machine remotely since last login. I was assuming that since I could log into it with ssh, it is up and in a running state, but maybe that's not the case?

gengisdave 01-09-2014 03:27 AM

files starting with '.' are not affected by *, so it's like an empty dir, try 'cp .??* /home/bjornb/backup/etc-skel/'

Tachtory 01-09-2014 03:30 AM

Quote:

Originally Posted by gengisdave (Post 5094774)
files starting with '.' are not affected by *, so it's like an empty dir, try 'cp .??* /home/bjornb/backup/etc-skel/'

Thank you! I didn't know * ignored '.' files.

Works with '.*', what are the question marks for in '.??*'

gengisdave 01-09-2014 03:44 AM

a bit of explain: do a 'ls -la', you'll see there are two directories, '.' and '..'; '.' is the current directory, 'cd .' moves you in the directory you already are, while 'cd ..' moves you a level up

'*' is a _wildcard_ that means "any sequence of characters, but it can be empty", if you do 'cp .*', it will try to copy '..' directory too, and this cause problems

'?' is a wildcard that means "any single characters, and it must exists"; '.?' is equal to '..' so use two ? to avoid it

JJJCR 01-09-2014 03:52 AM

Quote:

Originally Posted by Tachtory (Post 5094776)
Thank you! I didn't know * ignored '.' files.

Works with '.*', what are the question marks for in '.??*'

.* and .??* - makes no difference it's the same.

* and ? are wildchars (check out this link: http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx)

* - means anything could be a single character or a group of characters

? - use to check only a single character

For example:

Politicians ?UCKs

the ? can stand for any character either a letter, number or a symbol. Or whatever your definitions for Politicians. :)

goumba 01-10-2014 09:09 AM

Quote:

Originally Posted by gengisdave (Post 5094783)
'*' is a _wildcard_ that means "any sequence of characters, but it can be empty", if you do 'cp .*', it will try to copy '..' directory too, and this cause problems

'?' is a wildcard that means "any single characters, and it must exists"; '.?' is equal to '..' so use two ? to avoid it


I've never had that happen by specifying 'cp .*'. Without -R specified, I get

Code:

cp: omitting directory ‘.’
cp: omitting directory ‘..’

With -R, those directories are silently ignored.


All times are GMT -5. The time now is 05:13 PM.