home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / res_diff < prev    next >
Text File  |  1992-03-10  |  1KB  |  54 lines

  1. :
  2. #
  3. #  res_diff /path/to/secure_directory current_report
  4. #
  5. #   This shell script just looks to see if anything has changed since
  6. # the last time... it just cuts out the first line (the date) and does
  7. # a diff... returns a 0 if it has changed, a 1 otherwise...
  8. #
  9. #  Started to use head and tail, but some SysV doesn't have 'em.  Bah!  Who
  10. # needs 'em anyway, when you have awk :-)
  11. #
  12. #
  13. # Explicitly specified pattern to match only report files
  14. # (yyyy_Mon_dd), so as to allow us to store other sorts of things
  15. # in the hostname subdirectories as well.  -- PASR 11/01/91
  16. DIFF=/bin/diff
  17. TEST=/bin/test
  18. AWK=/bin/awk
  19. LS=/bin/ls
  20. RM=/bin/rm
  21. ECHO=/bin/echo
  22. TOUCH=/bin/touch
  23.  
  24. #
  25. # Important files:
  26. if $TEST -d "$1" ; then
  27.     old_file=`$LS -t $1/[0-9][0-9][0-9][0-9]_[A-Z][a-z][a-z]_[0-9]* | $AWK 'NR==1'`
  28. else
  29.     $ECHO Error -- directory $1 does not exist for $0
  30.     exit 2
  31.     fi
  32.  
  33. if $TEST x"$old_file" = x ; then
  34.     # No previous file exists -- make an empty one.
  35.     old_file=$1/1776_Jul_4
  36.     $TOUCH $old_file
  37.     fi
  38.     
  39. # has anything changed?
  40. $AWK 'NR > 5' $old_file > /tmp/tmp.$$.foo
  41. $AWK 'NR > 5' $2 > /tmp/tmp.$$.bar
  42.  
  43. if $TEST -n "`$DIFF /tmp/tmp.$$.foo /tmp/tmp.$$.bar`" ; then
  44.     $RM -f /tmp/tmp.$$.foo /tmp/tmp.$$.bar
  45.     $ECHO There is a difference....
  46.     exit 1
  47.     fi
  48.  
  49. $RM -f /tmp/tmp.$$.foo /tmp/tmp.$$.bar
  50. # echo There is no difference....
  51. exit 0
  52. # end
  53.