LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 10-05-2011, 12:45 AM   #16
gnif
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled

Or you could just turn the option on in bash so that * matches dotfiles.

shopt -s dotglob
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-28-2011, 09:25 AM   #17
jrdasm
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Rep: Reputation: 0
Easier way:
Code:
cp -r source/. target/
Will result in ".a" file in source/ to be copied in target/.a for example.
This way, all files will be copied, including hidden ones, and this syntax does not depend on the type of shell you use and the configuration of it.
 
Old 12-28-2011, 04:34 PM   #18
gnif
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
But doing this with the recursive flag will cause cp to recurse up directories in some circumstances, especially if the mv command is used. My solution is more correct because it makes the glob operator (*) work as expected for scripts and other commands also.
 
Old 12-29-2011, 03:11 AM   #19
jrdasm
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Rep: Reputation: 0
Quote:
will cause cp to recurse up directories in some circumstances
No it doesn't
Quote:
especially if the mv command is used
The question is about "cp".
 
Old 12-29-2011, 03:31 AM   #20
gnif
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
Yes, sorry, I was thinking of when a for loop is used and the shell expands the . and .. paths.

And yes, I know this questions is about cp, but you will get some people that try the same trick with other commands such as mv.
 
  


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
Copy files from multiple directories into one directory MadRabbit Linux - Newbie 8 02-07-2014 07:56 PM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 09:18 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 11:51 AM
home directory files gone, hidden files remain Grasshopper Linux - Security 12 04-10-2005 08:23 PM
Hundreds of hidden files in home directory doobers Linux - Newbie 3 02-14-2005 02:57 PM


All times are GMT -5. The time now is 04:49 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