Web Hosting Talk







View Full Version : Mass-replacing Files?


Mizu
08-22-2003, 08:08 PM
Admittedly, it's probably a simple answer that's right under my nose, but I am looking for some sort of SSH command(or software of some kind) that can mass-replace or even delete files of a certain name on a server. I require this to fix some vandalism that occured on to all of my server's index files.... I would like to switch them to plain blank pages instead. However, I can't find out any method of accomplishing this.
Any help at all is greatly appreciated. :D

unixtx
08-22-2003, 10:24 PM
I would highly suggest you verify the output of the find command, first, before blindly copying a new file file over to all of your index.html files, but something like the following should get you started:

touch blank.file
cp -f blank.file `find / -name index.html`

This will find all files on the entire server named index.html. If you keep a tidy server, and everything is under /home/vhost, for instance, and you wish to find all the index.php's:

cp -f blank.file `find /home/vhost -name index.php`

I am sure someone else can string together a much nicer script, but you get the idea ;)

Nedani
08-24-2003, 06:51 PM
vi /tmp/replacement.html - write your replacement file

find /website/folder -name index.html -exec cp -f /tmp/replacement.html \{\} \;