How can I do this on the command line?
e.g. copy /dir/another/file to /tmp/ so I have /tmp/dir/another/file
cp --parents /dir/another/file /tmp
will do exactly what you want.
rsync can be a good help for this :
rsync -Ravz my/first/dir/file.txt another_dir
will gave as result
You can use tar to preserve paths while copying files:
tar cf - /dir/another/file | (cd /tmp && tar xf -)
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the
terms of service.
10 months ago
8 months ago