home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchk294s.zip / ftnchek-2.9.4 / test / Compare.sh.distrib < prev    next >
Text File  |  1996-10-04  |  983b  |  41 lines

  1. #!/bin/sh
  2. #
  3. # Bourne shell script to compare File in directory ./Vary with
  4. # original in directory ./Okay and print differences if any.
  5. # If no differences it echoes a dot to show progress.
  6. # If differences, touches file CHECK_FAILED
  7. #
  8. # Usage: Compare.sh Okay Vary File
  9.  
  10. OKAY=$1
  11. VARY=$2
  12. FILE=$3
  13.  
  14.     if [ ! -d ${OKAY} ] ;
  15.     then
  16.         echo "Creating directory ${OKAY}" ;
  17.         mkdir ${OKAY};
  18.     fi
  19.     if [ ! -f ${OKAY}/${FILE} ] ;
  20.     then
  21.         echo "${FILE} is new" ;
  22.         /bin/cp ${FILE} ${OKAY}/${FILE} ;
  23.     fi
  24.     if /usr/bin/cmp ${OKAY}/${FILE} ${FILE} ;
  25.     then
  26.         /bin/rm -f ${FILE} ;
  27.         echo '.' | gawk '{printf("%s",$1);}' ;
  28.     else
  29.         touch CHECK_FAILED
  30.         echo "--------------------------------------------------" ;
  31.         echo "Differences in ${OKAY}/${FILE}  ${VARY}/${FILE} :" ;
  32.         if [ ! -d ${VARY} ] ;
  33.         then
  34.         echo "Creating directory ${VARY}" ;
  35.         mkdir ${VARY} ;
  36.         fi
  37.         /bin/mv ${FILE} ${VARY}/${FILE} ;
  38.         /usr/bin/diff ${OKAY}/${FILE} ${VARY}/${FILE} ;
  39.     fi
  40.     exit 0
  41.