Copy one file into every subdirectory

bash, scripting, shell

Solution

Try this :

find . -type d -exec cp index.php {} \;

Note

- `-type d` find all dirs and sub-dirs

Problem

I'm trying to `cp` one file: `index.php` into all subdirectories, and subdirectories of those subdirectories, and so on, so that every child directory of the root has `index.php` I started with this: ``` for d in */; do cp index.php "$d"; done; ``` Which only worked for the top subdirectories. I tried to nest it in itself a few times like this: ``` for d in */; do cp index.php "$d"; for e in */; do cp index.php "$e";for f in */; do cp index.php "$f"; done; done; done ``` But that didn't seem to do anything

Original source