What am I doing wrong?
Brace expansion generates multiple arguments. cp
does not see what you type, it sees what the shell provides after it expands what you typed. cp
does not support multiple targets, it supports multiple sources though. In your (expanded) command only the last argument is interpreted as a target. All but one arguments resulting from the brace expansion are considered to be additional sources.
target_folder1 is a directory (not copied)
means target_folder1
is interpreted as a source but it was not copied because directories cannot be copied unless you use -R
or equivalent option.
To copy to multiple destinations you can adapt the solution from this answer. In your case there is a single file to be copied, so it would be like:
<source_folder/source.json tee target_folder{1..11}/source.json >/dev/null
Note tee
reads the source file just once. With cp
the most obvious solution is to loop over destinations and call a separate cp
process for each. This would read the file many times though. In your case it may not matter much, but if the file was large then you certainly wouldn't want to read it eleven times.