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 05-13-2010, 08:40 AM   #1
ringding
LQ Newbie
 
Registered: Feb 2005
Distribution: RH9, RHEnt.
Posts: 23

Rep: Reputation: 0
Help in replicating a directory to another directory.....


I have a directory /sanvol/ifr/ which contains 90,000 files and 2 subdirectories containing 60,000 files. I need to copy the contents of /sanvol/ifr to /sanvol/edm/.

The cp command will not work because there are too many files.

I tried the following:
find /sanvol/ifr/ type f -name '*' -exec cp -p {} /sanvol/edm/. \;

but this copies all files including whats in the subdirectories to /sanvol/edm/

I need to replicate exactly the contents of /sanvol/ifr/ to /sanvol/edm/ and preserve file attributes and dates.

Thanks for the help guys...
 
Old 05-13-2010, 08:43 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
rsync -avz olddirectory newdirectory
or
(cd olddirectory && tar cSlpf - . ) | (cd newdirectory && tar xSpfv -)

EDIT:

Oops! Just saw the "no subdirectories" requirement.

find /sanvol/ifr/ -maxdepth 1 type f -exec cp -p {} /sanvol/edm/. \;

Last edited by catkin; 05-13-2010 at 08:47 AM.
 
Old 05-13-2010, 08:52 AM   #3
ringding
LQ Newbie
 
Registered: Feb 2005
Distribution: RH9, RHEnt.
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
rsync -avz olddirectory newdirectory
or
(cd olddirectory && tar cSlpf - . ) | (cd newdirectory && tar xSpfv -)

EDIT:

Oops! Just saw the "no subdirectories" requirement.

find /sanvol/ifr/ -maxdepth 1 type f -exec cp -p {} /sanvol/edm/. \;
Hi catkin!,
wow..that was fast....I don't think I did a good job in describing my situation.

I actually need to copy exactly the contents of /sanvol/ifr/ (including subdirectories) to /sanvol/edm/ and preserve file attributes and dates.

I think the rsync command will work for that correct? So I can use rsync even though I am not connecting to a remote machine?
 
Old 05-13-2010, 10:03 AM   #4
ringding
LQ Newbie
 
Registered: Feb 2005
Distribution: RH9, RHEnt.
Posts: 23

Original Poster
Rep: Reputation: 0
rsync worked perfectly! Thanks catkin!
 
  


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
Username & Password Sync Fedora Directory and Microsoft Active Directory karnac01 Fedora 4 07-19-2010 12:51 AM
change default vsftp anonymous accout directory /var/ftp to other directory? hocheetiong Linux - Newbie 2 01-24-2010 06:33 PM
Active Directory User Cannot Write to Samba Home Directory jonwatson Linux - Networking 2 12-19-2006 12:40 PM
LXer: Directory services made easy with Fedora Directory Server LXer Syndicated Linux News 0 12-08-2006 03:54 AM
How to protect a file/directory in your home login directory (RH Linux) jitsenho Linux - Security 9 07-03-2006 11:08 PM


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