This question is a sequel of sorts to my earlier question, Creating numerous directories using
I am using the
bash shell. I have created fifty directories, each starting with the prefix "s", using the command:
mkdir $(printf "s%02i " $(seq 1 50))
which pads to the second digit with zeros. That is, the directories that I obtain are of the form
Now I would like to use
cp to copy a single file (for example,
test.txt) to each of the fifty directories. Is it possible to do this in a way analogous to that above? For example, would the following work? I am relatively new to Unix/Linux, so I don't really want to try this until someone please gives me an indication that it is safe.
cp test.txt $(printf "s%02i.txt " $(seq 1 50))
Looking at the
man page for
cp, it does not look like
cp supports multiple destinations like this, however:
NAME cp - copy files and directories SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too.