LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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: 328

Rep: Reputation: 74
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: 328

Rep: Reputation: 74
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: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
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: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
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



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 3 04-14-2020 04:08 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 01:14 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
Open Source Consulting | Domain Registration