Copying folder to multiple destinations in parallel [duplicate]
I know little about Mac OSX, still I believe its standard tools are similar to ones in Linux.
If it was for Linux/Bash I would try:
tar -c /source/dirA/ /source/file1 | tee >(cd /foo/destination3/ && tar -x) >(cd /bar/destination2/ && tar -x) >(cd /foobar/destination1/ && tar -x) > /dev/null
Every destination will receive dirA/
and file1
. You may give more arguments to the first tar
(directories or files). In order to add another destination simply put additional tee
argument in similar manner.
How does it work? First tar
converts directories and files to a single bitstream that can be used in a pipe. The tee
command forks that stream; every copy but one is extracted by tar
in proper destination. The last copy moves down the pipe; it is discarded into /dev/null
. (One may use the last copy for destination0
but the syntax would be different so I decided to keep it simple with tee
only).
The code is a starting point. You may need to adjust it to work with OSX.