Copying the files in to multiple location using shell script

Hi All,

i'm trying to copy the 1.txt files (sample files) in to different path location using the below command.
But it is not copying the files , when i tried for single location able to copy the file.
can any one please assist here.

Please find the below path :-

/ckr_mkr1/licencekey

file name: 1.txgt

source location : /ckr_mkr1/licencekey/1.txt
Destination location : /ckr_mkr5*/licencekey/1.txt (eg : ckr_mkr3 , ckr_mkr4 , ckr_mkr5 ..... ckr_mkr40 )

i tried the below command ..but it is not copying in destination location .
using the find commmand

 find . -type f -name "1.txt" -exec cp "{}" -nR /ckr_mkrlive*/licencekey/

using the copy command

cp -nr /ckr_mkr*/licencekey/
 

Copying several files to one target directory can be done with cp . Not what you want to do - cp to several targets in one go. You'd need a loop, or e.g.

echo ckr_mkr3 ckr_mkr4 ckr_mkr5 ckr_mkr40 | xargs -n1 echo cp /p/t/f/1.txt
cp /p/t/f/1.txt ckr_mkr3
cp /p/t/f/1.txt ckr_mkr4
cp /p/t/f/1.txt ckr_mkr5
cp /p/t/f/1.txt ckr_mkr40

where /p/t/f is the "path to file". Supply full target paths if necessary. You could use any other means to provide the targets on stdin, like a file, or an ls command, ...

The find command provides a list of files/directories according to some criteria. To use it you must do it the other way round, i.e. let it provide a list of directories to copy a fixed file to, like this:

find /start/dir -type d -name "<name-pattern>" -exec cp /a/fixed/file.txt {} \;

If you have a list of files you want to copy you can do that by enclosing the command in a loop:

for filetocopy in /some/where/* ; do
     find /start/dir -type d -name "<name-pattern>" -exec cp "$filetocopy" {} \;
done

I hope this helps.

bakunin