How to copy file preserving directory path in Linux?

Posted by gasan on Server Fault See other posts from Server Fault or by gasan
Published on 2010-09-14T07:52:14Z Indexed on 2012/06/03 4:43 UTC
Read the original article Hit count: 517

Filed under:
|
|
|

I have Eclipse projects and ".project" file in them, the directory structure looks like 'myProject/.project'. I want to copy these '.project' files to another directory, but I want the enclosing directory name to be preserved.

Let's say I have 'a/myProject/.project', I want to copy 'myProject/.project' to 'b', so it be 'b/myProject/.project', but 'b/myProject' doesn't exist. When I try in a:

 cp -r ./myProject/.project ../b

it copies only '.project' file itself, without 'myProject' directory. Please advise.

© Server Fault or respective owner

Related posts about linux

Related posts about file