home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
- #
- # $Id: replace,v 1.1 93/11/19 13:53:11 carlson Exp $
- #
- # This script will search a number of files for a string
- # and replace the string. Sort of a global find-and-replace.
- #
- # Format of call:
- # replace <search-string> <replace-string> <file-list>
- #
- # Where:
- # <search-string> Is a regular expression (as used in ed)
- # that is supposed to be found in the list
- # of files.
- # <replace-string> Is the string that is to replace the
- # <search-string>.
- # <file-list> List of files to perform the find-and-
- # replace on.
- #
- # Revision History:
- # $Log: replace,v $
- # Revision 1.1 93/11/19 13:53:11 carlson
- # Initial revision
- #
- # 6 Jun 1989 Christopher W. Carlson, Silicon Graphics Inc.
- # Initial draft.
- #
- #---------------------------------------------------------------------------
- if ( argc < 4) then
- echo "Usage: replace <search-string> <replace-string> <file-list>"
- exit
- endif
-
- set noglob
- set search = $1
- shift
- set replace = $1
- shift
- unset noglob
-
- foreach file ( $* )
- echo "Doing $file:"
- sed -e "s/$search/$replace/gp" < $file > tmp$$
- if ( $status == 0 ) mv tmp$$ $file
- end
-