Replace all copies of a file under Linux

Today, after making a change to a php file, I had to update all copies of this file with the changes. The following command will update all files with the same name. Note that this will only work as expected if the name is unique. A theoretically better way to do it would be to find all files with a certain hash.

Anyways, here’s the linux shell command. First copy the updated file into the current directory (/tmp for example):

find /target_path/ -iname "some_file.php" -exec cp new_file.php '{}' \;

June 15, 2011 at 12:22 PM in Linux is a collection and semi organised thought process on web, development and technology news by Sander van Dragt.