home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / bin / kswaps < prev    next >
Encoding:
Text File  |  1990-01-19  |  519 b   |  28 lines

  1. #!/bin/csh
  2. # kswaps: global substitution of two strings for a set of files
  3. # syntax: kswaps string1 string2 filenames
  4. #
  5.  
  6. switch ($#argv)
  7.     case '0':
  8.     case '1':
  9.     case '2':
  10.         echo 'kswaps: Too few arguments!'
  11.         echo 'Usage: kswaps string1 string2 filenames'
  12.         exit -1
  13.         breaksw
  14.     default:
  15.         breaksw
  16. endsw
  17.  
  18. set host = `hostname`
  19. set files = `ls $argv[3-]`
  20. set tmpfile = /tmp/${host}.$$.kswap
  21.  
  22. foreach file ($files)
  23.     echo Swapping $1  $2 for $file...
  24.     sed -e "s/$1/$2/g" $file > $tmpfile
  25.     mv -f $tmpfile $file
  26. end
  27. echo Done.
  28.