#! /bin/ksh #Find all files that contain "Copyright 1995-1998" all_files=`ls *.html` print "$all_files" change_list="" for file in $all_files do print "Now working on $file" anything=`egrep "Copyright 1995-1998" <$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/1995-1998/1995-1999/g' <$file >new_files/$file done #cp new_files/* . # end of code