0

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.

marked as duplicate by don_crissti, Archemar, GAD3R, terdon Apr 13 '17 at 14:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

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.