#!/bin/ksh # # a script to globally change a string in a set of files # RCW 9/2/97 # # originally built to change carl mazur's email address from # cherryhillcp@freenet.hamilton.on.ca to ccp@vaxxine.com # DIR="." #PAT1=cherryhillcp@freenet.hamilton.on.ca #PAT2=ccp@vaxxine.com #PAT1="Credit:[ ]*Photograph by" #PAT1="Credit:[ ]*Photographs by" #PAT1="Credit:[ ]*Photo.* by" #PAT1="Credit:\([^{]*\) {" #PAT2="Credit:\1, {" PAT1="Credit:\([^{]*\)}" PAT2="Credit:\1)" #PAT1="Credit:\([^,]*\),$" #PAT2="Credit:\1" #set -x find $DIR -type f -name "*.htm" | xargs grep -l "$PAT1" > /tmp/files.$$ cat /tmp/files.$$ | while read sedfile do #echo "sed -e 's/$PAT1/$PAT2/' < $sedfile > $sedfile.tmp" sed -e "s/$PAT1/$PAT2/" < $sedfile > $sedfile.tmp mv $sedfile.tmp $sedfile #grep $PAT2 $sedfile done nrm /tmp/files.$$