LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-20-2006, 12:15 AM   #1
astrollama
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Rep: Reputation: 0
Copying Directories using cp -r


I am copying a directory using cp -r to another directory.
However both the from and to directories have subdirectories of the same name.
I want directory As subdirectories - their contents, put into directory Bs subdirectories of same name
ie A/a/1.txt and B/a/ already exist, I want 1.txt to go into B/a/

My command is cp -r /A/* /B/ which runs, but doesnt put the As subdirectories contents in Bs subdirectories. Is there a command to actually do this, or do I have to go through all the subdirectories and copy them separately? (which I dont want to do as there are 100s)
 
Old 10-20-2006, 12:37 AM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Either you've made a typo in your post, or in your command, but what you're trying to do is right.

Here's what you posted (and what's wrong):

cp -r /A/* /B/

Here's what it should be

cp -r ./A/* ./B/

or simply

cp -r A/* B/

I like to throw a -v in there too to see what's happening.

(I assume you see what's wrong - /A means find a directory called 'A' in the root of the file system - which almost certainly doesn't exist... same for /B. './A' or just 'A/' says look in the current directory for a directory called 'A')

Last edited by BrianK; 10-20-2006 at 12:39 AM.
 
Old 10-20-2006, 01:15 AM   #3
astrollama
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Original Poster
Rep: Reputation: 0
OK, Ive figured it out, the qry actually did work...
 
  


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
copying directories johnvillegas Slackware 4 03-11-2006 06:49 AM
Copying Hidden Directories Guru3 Linux - General 1 12-05-2003 12:59 PM
SAMBA copying directories thineonly Linux - Networking 6 02-11-2003 04:22 PM
Copying directories NetScripter Linux - Newbie 3 05-25-2002 12:48 AM
copying directories jonfa Linux - General 2 11-08-2001 10:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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