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 09-18-2006, 11:10 PM   #1
ryedunn
Member
 
Registered: Jul 2003
Location: Chicago
Distribution: Fedora, ubuntu
Posts: 459

Rep: Reputation: 30
merge directories


Im stuck with a problem that occured when attempting to copy a large directory which got interupted half way.

some of the files are in mp3/mp3/artist
others are located in mp3/artist

some are duplicated but I cant be sure all are in either directory but I do know one is larger than another.

I would like to merge the two directories overwriting is fine as long as it is the same file. When I try now the only option I get is to overwrite the whole artist directory which could be bad if the overwitten dir has files the other does not.

Your thoughts on the best solution?
Thank you
 
Old 09-19-2006, 03:20 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Well, if you were using a basic copy eg
/mp3/artist> cp * /mp3/mp3/artist
and it got interrupted, it just means that some files didn't make it to the target dir.
Just run the cmd again and it'll cp them all from scratch.
Before you start make sure you've 'fixed' whatever caused the original drop-out.
If you've changed some files in the tgt dir since the aborted cp and don't want to lose the changes, you can use the find cmd with the -mtime option to put them somewhere else first.
 
Old 09-19-2006, 09:23 PM   #3
ryedunn
Member
 
Registered: Jul 2003
Location: Chicago
Distribution: Fedora, ubuntu
Posts: 459

Original Poster
Rep: Reputation: 30
I caused the inturruption, that should be fixed.

and I believe I was using mv.

manual I guess?
 
Old 09-20-2006, 02:28 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
cp (or mv ) can only operate on files that exist in src dir, so you can't overwrite files in the tgt dir that you don't have in the src dir...
I'm not entirely clear on your 1st post there...
The 2 cmds operate at the file level, not dir level, as as a dir is a file in Linux, if you 'mv' a dir, all it does is change it's name.
If you worried about some kind of recursion effect, create a new temp dir, cp (not mv) all the files you want preserved into the temp dir, then sort out your final tgt dir structure/names and cp all the files into it.
Unless renaming a file or dir, i'd advise always use cp for multiple file 'moves' just in case of accidents (unless space is a real prob).
 
Old 11-15-2006, 10:02 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by chrism01
. . . if you 'mv' a dir, all it does is change it's name.
Well, usually. If the mv is taking place between file systems, i.e. drives or partitions, then mv does a copy followed by an erase. If you are in this situation & the data is important, then it's better to do the steps manually: a cp, a verify (e.g. diff or cmp loop), & only then an rm.
 
  


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
Concatenate binary file iftiuk Linux - General 6 05-16-2005 09:11 AM
perl: concatenate arrays jrtayloriv Programming 2 01-23-2005 08:13 AM
how to concatenate variable name in Java ? black Programming 1 11-16-2004 05:08 AM
Javascript concatenate two numbers Linh Programming 3 09-25-2003 01:29 PM
concatenate binary files???? justin19fl Linux - Newbie 6 05-14-2001 03:13 PM


All times are GMT -5. The time now is 12:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration