LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-13-2009, 10:22 PM   #1
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Rep: Reputation: 30
How do I copy over directories to directories with the same name without overwriting?


Say I have a bunch of directories for example:

Code:
/var/lib/a/
/var/lib/b/
/var/lib/c/
I have another external hard drive with these directories:

Code:
/var/lib/d/
/var/lib/e/
/var/lib/f/
I want to copy over /var/lib/{d,e,f} to the first /var/lib/ directory, without making {a,b,c} disappear. Won't "cp -R var/lib/* /var/lib/" erase a, b, and c? So the result would be:

Code:
/var/lib/d/
/var/lib/e/
/var/lib/f/
instead of:

Code:
/var/lib/a/
/var/lib/b/
/var/lib/c/
/var/lib/d/
/var/lib/e/
/var/lib/f/
(which is how I'd want it)
 
Old 03-14-2009, 01:09 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
cp only copies what you tell it. If there's no overlaps ie only one drive has a,b,c and the other only has d,e,f you should be good to go.
Easiest way to go (as in a lot in Linux) is to create a few test dirs elsewhere eg
diskA
/tmp/a, /tmp/b
diskB
/tmp/c, /tmp/d

and test the cmd on them....
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy recursively across directories stefaandk *BSD 1 11-09-2008 10:01 PM
How to copy directories sofasurfer Debian 10 01-01-2008 07:42 PM
copy command cp -R does not recurse directories ankuryu DamnSmallLinux 1 05-15-2007 06:35 AM
Copy files from different directories fiomba Linux - Software 3 02-11-2005 03:01 AM
copy directories and subdirectories Red Squirrel Linux - Newbie 2 03-06-2004 09:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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