Skip to content

Copy a file to multiple locations in linux

November 13, 2015 Commandline

How to copy a file to multiple locations in linux. cp doesnt let you copy one file to multiple locations;
There are a few ways to do this, but the one I always return to uses find

To copy the contents of a directory to multiple other directories


find /location/to/folder -maxdepth 0 -type d -exec cp -r /location/to/other/folder/* {} \;

To copy a single file to multiple other directories


find /location/to/folder/file.txt -type f -exec cp -r /location/to/other/folder/ {} \;

To copy a directory and its content into another directory


find /location/to/folder -maxdepth 0 -type d -exec cp -r /location/to/other/folder/ {} \;

You must be <a href="https://jonathansblog.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fjonathansblog.co.uk%2Fcopy-a-file-to-multiple-locations-in-linux">logged in</a> to post a comment.