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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-13-2012, 04:10 AM
|
#1
|
LQ Newbie
Registered: Jan 2011
Posts: 5
Rep:
|
Copy Directories and its files to a new directory just as it is
Hi
I want to copy all files and subdirectories to a new directory as it is.
~/Documents/folder to ~/avr/newfolder
folder has subdirectories f1 f2 f3 and files within them. cp command is just not helping. Creating newfolder yes but without f1 f2 f3
Am i missing an option? cp -a isnt working for me.I am using Ubuntu 12.04
|
|
|
07-13-2012, 04:19 AM
|
#2
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Hi,
what exactly is happening when you use cp -a. Ie when you run
Code:
cp -a ~/Documents/folder ~/avr/newfolder
?
Evo2.
|
|
|
07-13-2012, 04:21 AM
|
#3
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,218
Rep:
|
Code:
cp -ar ~/Documents/folder ~/avr/newfolder
|
|
|
07-13-2012, 04:27 AM
|
#4
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Hi,
Quote:
Originally Posted by Didier Spaier
Code:
cp -ar ~/Documents/folder ~/avr/newfolder
|
Hmm, my cp (GNU coreutils 8.13) man page indicates the '-a', is the same as '-dR --preserve=all', and that '-R' is the same as '-r'. What version do you have?
Evo2.
|
|
|
07-13-2012, 04:32 AM
|
#5
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,218
Rep:
|
Well, I have the same - in fact I didn't check the man page
|
|
|
07-13-2012, 04:38 AM
|
#6
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Hi,
Quote:
Originally Posted by Didier Spaier
Well, I have the same - in fact I didn't check the man page
|
Ahh, ok. I don't normally use cp for recursive stuff preferring rsync, so my memory of cp options was quite fuzzy.
Cheers,
Evo2.
|
|
|
07-13-2012, 04:47 AM
|
#7
|
LQ Newbie
Registered: Jan 2011
Posts: 5
Original Poster
Rep:
|
Well a little wierd.... my directory actually had space in it
Tried two codes with -a option
arundhyoti@Sarkar:~/Documents/from HOD$ cp -a Documents/from\ HOD avr/fromHOD
cp: cannot stat `Documents/from HOD': No such file or directory
arundhyoti@Sarkar:~/Documents/from HOD$ cp -a Documents/from* avr/fromHOD
cp: cannot stat `Documents/from*': No such file or directory
but now
cp -a ~/Documents/"from HOD" ~/avr/fromHOD
worked! cant understant why the other two codes didnt work though
|
|
|
07-13-2012, 04:50 AM
|
#8
|
LQ Newbie
Registered: Jan 2011
Posts: 5
Original Poster
Rep:
|
OMG! I cant believe I missed the home in the path name. So thats y it wasnt't working!
Thanks for your replies
|
|
|
All times are GMT -5. The time now is 06:40 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|