Really simple script I made awhile ago for recursively copying an indexing PHP script into a directory tree on my webserver.
Instead of recursively copying files within directories to another location, this script copies a single file into every sub-folder of the destination.
Code:
#!/bin/bash
#
# recursiveCopy.sh
#
# Description:
# Program that copies a specified file into a specified directory
# recursively. In other words, it copies a file to a directory
# and into each of its sub-directories
#
# Check for the right number of command line arguments
if [ $# != 2 ]; then
echo "Usage: ${0} /path/to/file /path/to/directory"
exit
fi
# Check to make sure the specified file actually exists
if [[ ! -e ${1} ]]; then
echo "Error: File ${1} does not exist"
exit
fi
# Check to make sure the specified directory exists
if [[ ! -d ${2} ]]; then
echo "Error: Directory ${2} does not exist"
exit
fi
# Search for directories inside the current directory, loop, copy
find ${2} -type d | while read DIR; do cp ${1} $DIR/; done