LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-09-2014, 03:18 AM   #1
Tachtory
Member
 
Registered: Dec 2011
Distribution: Mint, Slackware
Posts: 43

Rep: Reputation: Disabled
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?
 
Old 01-09-2014, 03:27 AM   #2
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 326

Rep: Reputation: 73
files starting with '.' are not affected by *, so it's like an empty dir, try 'cp .??* /home/bjornb/backup/etc-skel/'
 
Old 01-09-2014, 03:30 AM   #3
Tachtory
Member
 
Registered: Dec 2011
Distribution: Mint, Slackware
Posts: 43

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gengisdave View Post
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 '.??*'
 
Old 01-09-2014, 03:44 AM   #4
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 326

Rep: Reputation: 73
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
 
Old 01-09-2014, 03:52 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,297

Rep: Reputation: 222Reputation: 222Reputation: 222
Cool

Quote:
Originally Posted by Tachtory View Post
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.

Last edited by JJJCR; 01-09-2014 at 03:53 AM. Reason: edit
 
Old 01-10-2014, 09:09 AM   #6
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,161
Blog Entries: 7

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Quote:
Originally Posted by gengisdave View Post
'*' 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.

Last edited by goumba; 01-10-2014 at 09:13 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] tar.gz: Cannot stat: No such file or directory windstory Linux - Newbie 2 09-07-2011 08:40 AM
Tar problem; Cannot stat: No such file or directory rn-pro Programming 3 10-07-2010 02:53 AM
cannot stat /etc/X11/X (no such file or directory) theabyyss Linux - Software 2 02-12-2008 07:15 PM
lsattr: no such file or directory while trying to stat... acampbell Linux - General 6 12-01-2003 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration