LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-13-2008, 09:14 PM   #1
ceantuco
Member
 
Registered: Mar 2008
Location: New York
Distribution: Debian
Posts: 809

Rep: Reputation: 88
Smile command to copy a directory


Hi Guys,

I was trying to copy a directory from one place to the other one (local HD) but the cp command doesn't allow me to copy the entire directory. I was able to copy files from there but no directories.
Thanks
 
Old 09-13-2008, 09:22 PM   #2
sasho
Member
 
Registered: Jan 2005
Distribution: Arch
Posts: 120

Rep: Reputation: 17
cp -r will copy recursively
 
Old 09-13-2008, 10:44 PM   #3
ceantuco
Member
 
Registered: Mar 2008
Location: New York
Distribution: Debian
Posts: 809

Original Poster
Rep: Reputation: 88
Thanks! the problem wasn't the command I was typing, it was the directory name (upper case/spaces and numbers) Thanks again!
 
Old 09-13-2008, 11:44 PM   #4
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Rep: Reputation: 15
use tab

lets say the directory is in /root with name "gappu pad"
type

cp -r /root/gap<press tab here> target
 
Old 09-14-2008, 04:56 PM   #5
Reasa
Member
 
Registered: Aug 2008
Distribution: Slackware
Posts: 53

Rep: Reputation: 16
for spaces in names i usually put them "into brackets".
 
Old 09-17-2008, 04:03 AM   #6
Ashok_mittal
Member
 
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
Quote:
Originally Posted by ceantuco View Post
Thanks! the problem wasn't the command I was typing, it was the directory name (upper case/spaces and numbers) Thanks again!
directory you want to copy is abc/ target is xyz/

cp -r abc/ xyz/

or if u want to copy a entire directory content then go in the directroy liks

cd qwe/

cp -r * xyz/
 
Old 09-17-2008, 04:09 AM   #7
bob_man_uk
Member
 
Registered: Jul 2003
Location: Malta
Distribution: Ubuntu/Windows/Mac
Posts: 83

Rep: Reputation: 16
directories with spaces "should" have a \ before the space for example


Code:
cp -r silly\ sally/
and this is what the direcotry layout looks like


Code:
root@debian:/home/mgilbert# ls
core       Desktop  Documents  Music     Public       smb4k      Videos
core.9688  dev      hdd        Pictures  silly sally  Templates
root@debian:/home/mgilbert#
 
  


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
Copy directory execlude directory linux2man Linux - General 3 12-12-2006 07:52 AM
How to copy one directory to another directory thru PHP? green_njk Programming 1 01-06-2006 06:55 AM
copy all of one filetype found by locate command to a single directory socratesone Linux - Software 3 06-22-2005 01:23 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 11:51 AM
how do I copy a whoel folder form one directory to another form the command line? zwyrbla Linux - Newbie 8 08-24-2004 06:40 PM

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

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