I'm running this command to find all the files named deploy.php in my whole project and make a copy of them and place them in the same directory as they were found, with name deploy_bkp.php

find . -type f -name "deploy.php" -exec cp  {} deploy_bkp.php  \; 

But it's not working recursively, it's only working for files on the top directory.


According to https://askubuntu.com/questions/497122/find-and-exec-in-found-folder you should use -execdir
Your command should look like this:

find . -type f -name "deploy.php" -execdir cp  {} deploy_bkp.php  \;

Not the answer you're looking for? Browse other questions tagged or ask your own question.