find and copy files into multiple directories
I have a client who wants me to write a script that finds php files and then duplicates them in their current directory. I want to input a starting directory and have this script descend into the directory hierarchy and update all of the php files.
This is what I figured out so far, thanks to this board:
find <start_directory> -iname "*.php" -exec cp {} <new_dir> \;
However, if i replace <new_dir> with a "." it places all of the duplicates in one directory.
I would like to copy the files to their current directory. I guess what i need is some kind of variable which represents the path location of the current file that is being found.
I searched the man pages and found %h, but i do not know how to use it in the find command for my purpose
i was thinking something like this, but it is not right:
find /www/ -iname "*.php" -exec cp {} %h%p \;
If anyone has a solution, I would very much appreciate your help.
Thanks,
Anthony
|