cp command problem..... unexpected result
I have this structure:
I want to copy /tempdir2/tempdir1/tempfile1 into tempdir3...
ie I want the stucture /tempdir2/tempdir1/tempfile1 in /tempdir3 not just the file tempfile1... :(
I used the command:
cp -p /tempdir2/tempdir1/tempfile1 tempdir3
This only copies tempfile1 into tempdir3. I want the structure from /tempdir2 onwards to go in there. Grrr!
It's like as if I'm just doing:
cp /tempdir2/tempdir1/temp1file1 tempdir3...
I'm using Redhat 8 and the man page isn't really clear on this. Any ideas?
If I read you correctly, you'd like to see the following as a end result:
One of the quickest ways I can see doing that is:
tar -cpf newcopy.tar tempdir2/tempdir1/tempfile1
tar -C tempdir3 -xpf newcopy.tar
that'll create ./tempdir3/tempdir2/tempdir1/tempfile1 for you, and only that. Using cp recursively would grab other files as well as tempfile1.
Yep, thats what I'm trying to do. The exerise (Sam's 24 hour book actually) was trying to show that you could pluck just one of the 3 files outta there without moving the whole lot... because that would have been easy, ie:
cp -r tempdir2/tempdir1 tempdir3 :)
I see you tar the structure and file and extract it inside tempdir3 instead. Another way. :) I see you use the -p parameter there too and that's what I had hoped would work with my cp line.
|All times are GMT -5. The time now is 02:55 AM.|