Click to See Complete Forum and Search --> : Recursive 'mv' command to move directory into another
movEAX_444
10-21-2004, 08:25 PM
I have a big file structure inside a dir, a lot of files, subdirs and sub-subdirs.. I have another dir which is supposed to replace some of these files (it's a patch).. It's too big to manually move each file into the required subdir, is there any command like mv that recurses and overwrites files if they exist? and just moves them in if they don't?
Fenster
10-21-2004, 08:49 PM
Try:
cp -R /original/dir /target/dir
and then...
rm -R /original/dir
Basically copy and paste over and then delete the original. I don't recall any recursive option for mv
gehidore
10-21-2004, 09:09 PM
As root
cd /subject/ ; tar cSpf - . | ( cd /target/ ; tar xSpf - )
Where /subject is the dir being copied and /target is the destination
the contents of /subject/ ( not the folder ) will be copied to /target/ , if you do /subject (it should) move the entire folder as well.
Then simply remove the old dir.
rm -r /subject
The advantage to this method is it preserves file permissions.