Linux – How to copy a single file and maintain directory structure

file managementlinux

How can I do this on the command line?

e.g. copy /dir/another/file to /tmp/ so I have /tmp/dir/another/file

Best Answer

cp --parents /dir/another/file /tmp

will do exactly what you want.

Related Question