С нами с 27.05.03
Сообщения: 95
Рейтинг: 6
|
Добавлено: 13/01/06 в 19:39 |
прямо на хостинге
Код: |
#!/bin/sh
# this is tiny script to find and replace one string by antother recursively directly on your hosting
# requirements - UNIX hosting, shell access
# it was written 11 Jan 2006 by me (owner of http:/www.pix43.com/main/) to update pages
#of galleries (duplicated thousands times) I used to submit years ago
#I'm not responsable for any damage this script can cause, please use carefully because it
#actually deletes files
# instructions:
# 1 - upload this file to your domain (it will run recursively in all subfolders relative to place where you run it)
# in ascii mode, CHMOD to 755
# 2 - change parameters FROM and TO to whatever you need.
# DONT'T FORGET TO ADD ESCAPE CHARACTERS. Add \ before each apperance of " and / after each apperance of \
# if you have blank spaces in original or replacing string, replace them by symbol ~
# see example to understand all said above.
# i highly recommend to put script first in some test subfolder and see how it works
# 3 - run it in COMMAND PROMPT either by "sh mfr.txt" or by "./mfr.txt"
# example of gallery before: http://www.erotofun.com/gallery/asians/japanese_model/pages/japanes
efore.html
# gallery after: http://www.erotofun.com/gallery/asians/japanese_model/pages/japanese_model_fdb.html
MATCHING_FILES_LIST='matching_files.txt'
#FROM='http:\/\/tgp.pix43.com\/main.shtml'
#TO='http:\/\/www.pix43.com\/main\/'
#FROM2='<img border=\"0\" src=\"http:\/\/www.pix43.com\/images\/free-tgp.gif\" alt=\"free tgp\" width=\"100\" height=\"54\">'
#TO2='<h1>xxx pix free<h1>'
FROM1='www.erotofun.com\/tgp.shtml'
TO1='www.pix43.com\/forum\/'
FROM2='Daily'
TO2=''
FROM3='Updated'
TO3=''
FROM4='XXX~Galleries'
TO4='xxx~pix~forum'
function replace()
{
counter=0
blank=" "
FROM=$1
FROM=${FROM//~/$blank}
TO=$2
TO=${TO//~/$blank}
rm $MATCHING_FILES_LIST
echo "Started searching for files with substring $FROM ..."
find . -name *.html -exec grep -q "$FROM" '{}' \; -print >> $MATCHING_FILES_LIST
echo "Finished looking for files.."
echo "Started replacing $FROM by $TO.."
cat $MATCHING_FILES_LIST | while read FILE_NAME
do
let counter=counter+1
echo "($counter) processing $FILE_NAME..."
sed -e "s/$FROM/$TO/g" $FILE_NAME >> $FILE_NAME.tmp
mv $FILE_NAME.tmp $FILE_NAME
done
}
replace $FROM1 $TO1
replace $FROM2 $TO2
replace $FROM3 $TO3
replace $FROM4 $TO4
|
|
|
|
|
Текстовая реклама в форме ответа Заголовок и до четырех строчек текста Длина текста до 350 символов Купить рекламу в этом месте! |