Bash – Make copies of a single directory to multiple directories with different names

bashcommandcommand lineosxshell-script

I'm trying to replicate a single directory (with sub-directories) to a bunch of new directories based on a list. For example I can:

mkdir Fred Barney Thelma Louise Foo Bar

How would I copy a premade directory (with some empty sub-directories) to the same set of names? For example:

cp -r master_folder/ Fred Barney Thelma Louise Foo Bar

Any suggestions much appreciated!

Best Answer

Use a loop to iterate over the directories you want it copied to and copy the contents of your master directory to each one:

dest=(Fred Barney Thelma Louise Foo Bar)
for d in "${dest[@]}"; do
    cp -r master "$d"
done
Related Question