replacelink.sh

 

###
### replacelink.sh
###


if [ $# -lt 1 ]; then
   echo "Usage: replacelink.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 "<a href=\"$oldterm\">" $i >/dev/null 2>/dev/null`
    then
       echo "Updating $i"
       sed "s/<a href=\"$oldterm\">/<a href=\"$newterm\">/g" $i > $i.tmp
       mv -f $i.tmp $i

       sed "s/<a href=\"\.\/$oldterm\">/<a href=\"$newterm\">/g" $i > $i.tmp
       mv -f $i.tmp $i

       sed "s/<a href=\"\/$oldterm\">/<a href=\"\/$newterm\">/g" $i > $i.tmp
       mv -f $i.tmp $i
    fi
 done