Copying a File to Multiple Locations

The following information is useful for creating a backup.

Code

To copy a file to multiple locations, use the following code:

Multiple Copies
xargs -n 1 cp -v foo.txt<<<"/tmp1/ /tmp2/ /tmp3/"

This code means that you are copying one file named foo.txt to multiple directories called /tmp1/, /tmp2/, and /tmp3/ using the xargs command. 

The xargs command constructs argument list(s) and executes utilities like cp.

Related Articles