lunes, 24 de mayo de 2010

Copy single file to multiple directories

Parent_Directoy
Filename1
Child_Directory1
Child_Directory2
Child_Directory3
Child_Directory4
....
So I need to copy Filename1 to all of the Child_Directories.

<!--ntstart--><b>find <parent directory> -type d -exec cp <parent directory>/<Filename1> {}/ \;</b><!--ntend-->

or in a bourne/shell script :
If you have other junk in the parent dir but a pattern that matches all subdirs (eg Child_Directory*), you can do this (bourne/ksh/bash):
<!--ntstart--><b>for subdir in <parent directory>/<pattern> ; do cp <parent directory>/<Filename1> ${subdir}/ ; done</b><!--ntend-->


No hay comentarios: