[ale] cp but maintaining path?
timothy at meanor.net
timothy at meanor.net
Wed Mar 12 15:56:19 EDT 2008
--snip--
>>I am working on a shell script that in the middle of it needs to copy
>>files (individually) from dir1 to dir2.
>>
>> The trouble is that there is directory structure below dir1 that I
>> want to recreate in dir2.
--snip--
If I understand you correctly, you have a directory structure similar to this:
/dir1/subdir1/file1
/dir2
and you want copy file1 to dir2, but maintaining the directory structure, so you end up with this:
/dir1/subdir1/file1
/dir2/subdir1/file1
but if there are other files in /dir1/subdir1, you don't necessarily want to copy them, so you can't just do "cd dir1;cp -pvR subdir1 /dir2". Is that correct?
--snip--
>>cd dir1
>>tar -cf - $relative-path | (cd dir2; tar -xf -)
>>cd dir2
>>
--snip--
That's how I'd do it. In some brief experimentation, I couldn't get rsync to create the directory structure underneath dir2 when I was specifying individual files (e.g. cd /dir1;rsync -va subdir1/file1 /dir2 puts file1 in /dir2, not /dir2/subdir1). Perhaps I was missing something.
--snip--
>>Thanks
>>Greg
>>--
>>Greg Freemyer
>>Litigation Triage Solutions Specialist
>>http://www.linkedin.com/in/gregfreemyer
>>First 99 Days Litigation White Paper -
>>http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf
>>
>>The Norcross Group
>>The Intersection of Evidence & Technology
>>http://www.norcrossgroup.com
--snip--
HTH
-Tim
More information about the Ale
mailing list