I have several files of the same name (say, somefile.php) scattered within several directories under /var/
If I want to replace all of them with a new version of somefile.php located in, say, /home/me/somefile.php ... how would I do that? Every search result I find relates to replacing text in a file but I want to replace the entire file.
I know I can find all the files with:
find /var/ -type f -name somefile.php
But I'm not sure how to move /home/me/somefile.php into the results and replace 'em all.
find /var -type -f -name somefile.php -exec cp /home/me/somefile.php {} \;
be careful!
As you see, this works with files with whitespaces too:
Is this what you wanted?
GNU-extension-free version:
find /var -name somefile.php | while read LINE; do cp /home/me/somefile.php "$LINE"; done