Some file copying help please

Rick Stevens rstevens at vitalstream.com
Tue Apr 19 22:58:20 UTC 2005


Waldher, Travis R wrote:
> I need to copy data from here
> 
> /dir1/dir2/dir3/dir4 
> 
> To 
> 
> /dir5/dir2/dir3/dir4
> 
> I need the path of dir2 on down to remain in tact.  But the top folder
> is changing.
> 
> I basically want to copy dir4 from one filesystem to another and retain
> it's path, short the name of the first directory (dir1/dir5).  Without
> having to manually go in and create dir2 and dir3, which are both empty.
> 
> IS there a way to make cp do this?  I can't find one, it just errors out
> stating that the destination path is invalid.  I'm struggling to find a
> way to get tar to do this well.
> 
> I have about 400 directories like this to copy, so I need to figure out
> a command line to script this sucker out.

How about:

	cp -a --parents /dir1/dir2/dir3/dir4/* /dir5/dir2/dir3/dir4
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-      A day for firm decisions!!!   Well, then again, maybe not!    -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list