LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-13-2012, 04:10 AM   #1
arundhyoti
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Rep: Reputation: 0
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
 
Old 07-13-2012, 04:19 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

what exactly is happening when you use cp -a. Ie when you run
Code:
cp -a ~/Documents/folder ~/avr/newfolder
?

Evo2.
 
Old 07-13-2012, 04:21 AM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,218

Rep: Reputation: Disabled
Code:
cp -ar ~/Documents/folder ~/avr/newfolder
 
Old 07-13-2012, 04:27 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

Quote:
Originally Posted by Didier Spaier View Post
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.
 
Old 07-13-2012, 04:32 AM   #5
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,218

Rep: Reputation: Disabled
Well, I have the same - in fact I didn't check the man page
 
Old 07-13-2012, 04:38 AM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

Quote:
Originally Posted by Didier Spaier View Post
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.
 
Old 07-13-2012, 04:47 AM   #7
arundhyoti
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
Old 07-13-2012, 04:50 AM   #8
arundhyoti
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Original Poster
Rep: Reputation: 0
OMG! I cant believe I missed the home in the path name. So thats y it wasnt't working!

Thanks for your replies
 
  


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 08:56 PM
Copy a directory into another directory while ignoring specific directories or files wh33t Linux - Newbie 14 05-16-2012 09:13 PM
[SOLVED] copy contents of many directories in a directory Nitesh Agarwal Linux - General 1 03-06-2012 11:04 AM
copy one large directory or multiple cp's on the sub directories superc0w Linux - General 7 12-15-2008 03:14 PM

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

All times are GMT -5. The time now is 06:40 PM.

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