Operating System - HP-UX
1834533 Members
2813 Online
110069 Solutions
New Discussion

Re: Copy file but not chang the original directory

 
Tieu Cong Thang
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
Dennis Handly
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 -
Tieu Cong Thang
Occasional Advisor

Re: Copy file but not chang the original directory

Thanks for your help, your answer is very helpful for me.
Dennis Handly
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.