lundi 29 décembre 2014

Find file, check size and overwrite when filesize is different


Today I found a little bug in my own written CMS. Now I want to rewrite all the files on the server with the same filename. However, I do have some customers with the specific file customized so I can't overwrite all of the files.


Since some customers have a customized file, I need to check the filesize.


When the filesize is different than it's source, it should overwrite. When it's the same filesize, it should skip the file.


A couple of months ago I asked a question a little similar, how-to overwrite multiple files from 1 source. I managed too fix this with:



echo /home/*/*/phpthumb | xargs -t -n 1 cp -r /home/test/testuser/phpthumb/*


Can I use this in a .sh script with a small if / else for rewriting or skipping the file? If yes, how can I accomplish this?


My unix experience is average so if something is not clear about my question, feel free to ask.


Kind Regards.



Aucun commentaire:

Enregistrer un commentaire