home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / test / Compare.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-19  |  891b  |  39 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. #
  7. # Usage: Compare.sh Okay Vary File
  8.  
  9. OKAY=$1
  10. VARY=$2
  11. FILE=$3
  12.  
  13.     if [ ! -d ${OKAY} ] ;
  14.     then
  15.         echo "Creating directory ${OKAY}" ;
  16.         mkdir ${OKAY};
  17.     fi
  18.     if [ ! -f ${OKAY}/${FILE} ] ;
  19.     then
  20.         echo "${FILE} is new" ;
  21.         cp ${FILE} ${OKAY}/${FILE} ;
  22.     fi
  23.     if cmp ${OKAY}/${FILE} ${FILE} ;
  24.     then
  25.         /bin/rm -f ${FILE} ;
  26.         echo '.' | awk '{printf("%s",$1);}' ;
  27.     else
  28.         echo "--------------------------------------------------" ;
  29.         echo "Differences in ${OKAY}/${FILE}  ${VARY}/${FILE} :" ;
  30.         if [ ! -d ${VARY} ] ;
  31.         then
  32.         echo "Creating directory ${VARY}" ;
  33.         mkdir ${VARY} ;
  34.         fi
  35.         /bin/mv ${FILE} ${VARY}/${FILE} ;
  36.         diff ${OKAY}/${FILE} ${VARY}/${FILE} ;
  37.     fi
  38.     exit 0
  39.