replace.sh

 

##!/usr/bin
 ###
 ### replace.sh
 ###
 ### Loop through every HTML file
 ### replacing old w/new  string
 ###
 ###
 ### To avoid permissions problems, run as root
 ###
 
if [ $# -lt 1 ]; then
   echo "Usage: replace.sh oldterm [ newterm ]"
   exit
else
   oldterm=$1
   newterm=$2
   echo "Replacing $oldterm with $newterm"
fi

 
 for i in `find . -name \*.htm* -print`
 do
    if  `grep $oldterm $i >/dev/null 2>/dev/null` 
    then
       echo "Updating $i"
       sed "s/$oldterm/$newterm/g" $i > $i.tmp
       mv -f $i.tmp $i
       chmod 777 $i
    fi
 done

 for i in `find . -name linklist.sh -print`
 do
    if  `grep $oldterm $i >/dev/null 2>/dev/null` 
    then
       echo "Updating $i"
       sed "s/$oldterm/$newterm/g" $i > $i.tmp
       mv -f $i.tmp $i
       chmod 777 $i
    fi
 done