#!/bin/csh
#
# Replace a string in some files.


set FILES= ($argv[3-])

foreach file ($FILES)
  if (-f $file) then
    echo $file
    sed "s|$1|$2|g" $file > $file.tmp
    if ($status == 0) then
      \mv -f $file.tmp $file
    else
      echo "replace failed."
      \rm -f $file.tmp
    endif
  endif
end
