home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / xpm / rename < prev    next >
Text File  |  2000-07-29  |  613b  |  25 lines

  1. #!/bin/sh
  2. # rename is provided to easily update code using sed-command files
  3.  
  4. USAGE='rename sed-command-file file1 file2...
  5.     apply all sed-command-file to the files file1 file2
  6. '
  7.  
  8. if test "$1" = '-?'; then echo "$USAGE";exit 1;fi
  9. commands=$1
  10. shift
  11.  
  12. for i in $*
  13. do if test -f $i
  14.    then echo -n "$i: "
  15.     echo -n "."
  16.     sed -f $commands $i > /tmp/rename.sed.$$;
  17.     if test ! -s /tmp/rename.sed.$$; then rm /tmp/rename.sed.$$; exit 1;fi
  18.     if cmp /tmp/rename.sed.$$ $i >/dev/null; then echo 
  19.     else cp $i $i.BAK; cp /tmp/rename.sed.$$ $i; echo " modified."
  20.     fi
  21.    fi
  22. done
  23.  
  24. rm -f /tmp/rename.sed.$$ /tmp/rename.sed.$$.org
  25.