0

I would like to copy the whole /usr/share/zoneinfo/ directory into /var/www/clients/client1/web5/./usr/share/zoneinfo/. (The /./ is added for clarity and formatting purposes)

The directory /var/www/clients/client1/web5/ exists, but the underlying usr/share/zoneinfo directory doesn't.

Is there a way to do this with a single command or do I have to call mkdir -p first ?

I thought cp --parents would do just that, but it seems it only works when copying a single file, not a whole directory.

0

Because you are specifying a destination location of /var/www/clients/client1/web5/./usr/share/zoneinfo/, cp will first look to make sure that directory exists to write files into. So yes, you will need to create the directory first. However, if /var/www/clients/client1/web5/./usr/share/ is already present, you should be able to:

cp -pr /usr/share/zoneinfo /var/www/clients/client1/web5/./usr/share/zoneinfo

as the destination directory exists to write the zoneinfo directory into.

0

rsync -a --relative did the trick.

rsync -a --relative /usr/share/zoneinfo/ /var/www/clients/client1/web5/

Credit goes to unix_ninja on this tweet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.