#! /bin/ksh #Find all files that contain #users.aol.com/johnf14246 #users.aol.com/gfsjohnf #members.aol.com/johnf14246 #members.aol.com/gfsjohnf all_files=`ls *.html surnames/*.html` print "$all_files" change_list="" for file in $all_files do print "Now working on $file" anything=`egrep "users.aol.com/johnf14246|users.aol.com/gfsjohnf|members.aol.com/johnf14246|members.aol.com/gfsjohnf" <$file` print "grepping $file" if [[ -n $anything ]] then change_list="$change_list $file" print "$file has been added to the change list." fi done #Copy these files to a safe place if [[ ! -d safe_place ]] then mkdir safe_place fi if [[ ! -d safe_place/surnames ]] then mkdir safe_place/surnames fi #cp $change_list safe_place #For each file replace old string with new string mkdir new_files for file in $change_list do print -n " now working on $file ... " cp $file safe_place/$file sed 's/users.aol.com\/johnf14246/www.rootsweb.com\/~jfuller/g' <$file | sed 's/members.aol.com\/johnf14246/www.rootsweb.com\/~jfuller/g' | sed 's/users.aol.com\/gfsjohnf/www.rootsweb.com\/~jfuller/g' | sed 's/members.aol.com\/gfsjohnf/www.rootsweb.com\/~jfuller/g' >new_files/$file print "done" done #cp -r new_files/* . # Write nasty email to Bill Gates saying "I could never have done this # with windows :-P" # mail -s "U R A Weenie" bgates@microsoft.com # The first three steps are optional but the last is obligatory ;-) # end of code