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.
brew install coreutils
and use gcp --parents /dir/another/file /tmp
Feb 27, 2019 at 13:42
rsync can be a good help for this :
rsync -Ravz my/first/dir/file.txt another_dir
will gave as result
another_dir/my/first/dir/file.txt
You can use tar
to preserve paths while copying files:
tar cf - /dir/another/file | (cd /tmp && tar xf -)