Copy a file to multiple locations in linux

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/ {} \;

Leave a Reply