#! /bin/ksh #Find all files that contain "bgcolor=\#ffffff" all_files=`ls *.html` print "$all_files" change_list="" for file in $all_files do print "Now working on $file" anything=`egrep "\#ffffff" <$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 mkdir safe_place cp $change_list safe_place #For each file replace old string with new string mkdir new_files for file in $change_list do sed 's/bgcolor=\#ffffff/bgcolor=\"\#ffffff\"/g' <$file >new_files/$file done #cp new_files/* . # end of code