General
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy file but not chang the original directory

 
Highlighted
Occasional Advisor

Copy file but not chang the original directory

I want to copy a file from one directory to another directory but I want to keep the soft directory of this file
Ex: I have file test in directory /lvbackup/log
anh now I copy this file to /lvbaclup/tmp
I the result I expect that:
/lvbaclup/tmp/lvbackup/log/test
Not using the mkdir to create directory before copy.
Can you help me???
Thankyou in advance
3 REPLIES 3
Highlighted
Acclaimed Contributor

Re: Copy file but not chang the original directory

>keep the soft directory of this file

(What does "soft" mean here?)

You can use tar(1) to copy the file and its parent directories.
$ cd /lvbaclup/tmp
$ tar -cf - -C / lvbackup/log/test | tar -xvf -
Highlighted
Occasional Advisor

Re: Copy file but not chang the original directory

Thanks for your help, your answer is very helpful for me.
Highlighted
Acclaimed Contributor

Re: Copy file but not chang the original directory

You haven't assigned any points yet. If our answers are useful, you should read the following and assign points:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33

If you have gotten all the answers you need on this threads' topic, you should close it.