Some file copying help please

Rick Stevens rstevens at vitalstream.com
Tue Apr 19 23:23:15 UTC 2005


Rick Stevens wrote:
> 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

DOH!  Try:

	cd /dir1
	cp -a --parents dir2/dir3/dir4 /dir5

(stupid!)
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
- Life:  That which happens while you search for the remote control. -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list