home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 200.img / SCO386X3.TD0 / bin / dircmp < prev    next >
Encoding:
Text File  |  1987-04-13  |  1.9 KB  |  89 lines

  1. :
  2. #    @(#) dircmp.sh 1.1 86/12/18 
  3. #
  4. #    Copyright (C) The Santa Cruz Operation, 1985.
  5. #    This Module contains Proprietary Information of
  6. #    The Santa Cruz Operation, Microsoft Corporation
  7. #    and AT&T, and should be treated as Confidential.
  8. #
  9.  
  10. PATH=/bin:/usr/bin
  11. USAGE="dircmp: usage: dircmp -s -d -wn directory directory"
  12. trap "rm -f /usr/tmp/dc$$*;exit" 1 2 3 15
  13. width=72
  14. set -- `getopt dsw: $*`
  15. if [ $? != 0 ]
  16. then
  17.     echo $USAGE
  18.     exit 2
  19. fi
  20. for i in $*
  21. do
  22.     case $i in
  23.     -d)    Dflag="yes"; shift;;
  24.     -s)    Sflag="yes"; shift;;
  25.     -w)    width=`expr $2 + 0 2>/dev/null`
  26.         if [ $? = 2 ]
  27.         then echo "dircmp: numeric argument required"
  28.             exit 2
  29.         fi
  30.         shift 2
  31.         ;;
  32.     --)    shift; break;;
  33.     esac
  34. done
  35. D0=`pwd`
  36. D1=$1
  37. D2=$2
  38. if [ $# -lt 2 ]
  39. then echo $USAGE
  40.      exit 1
  41. elif [ ! -d "$D1" ]
  42. then echo $D1 not a directory !
  43.      exit 2
  44. elif [ ! -d "$D2" ]
  45. then echo $D2 not a directory !
  46.      exit 2
  47. fi
  48. cd $D1
  49. find . -print | sort > /usr/tmp/dc$$a
  50. cd $D0
  51. cd $D2
  52. find . -print | sort > /usr/tmp/dc$$b
  53. comm /usr/tmp/dc$$a /usr/tmp/dc$$b | sed -n \
  54.     -e "/^        /w /usr/tmp/dc$$c" \
  55.     -e "/^    [^    ]/w /usr/tmp/dc$$d" \
  56.     -e "/^[^    ]/w /usr/tmp/dc$$e"
  57. rm -f /usr/tmp/dc$$a /usr/tmp/dc$$b
  58. pr -w${width} -h "$D1 only and $D2 only" -m /usr/tmp/dc$$e /usr/tmp/dc$$d
  59. rm -f /usr/tmp/dc$$e /usr/tmp/dc$$d
  60. sed -e s/..// < /usr/tmp/dc$$c > /usr/tmp/dc$$f
  61. rm -f /usr/tmp/dc$$c
  62. cd $D0
  63. > /usr/tmp/dc$$g
  64. while read a
  65. do
  66.     if [ -d $D1/"$a" ]
  67.     then if [ "$Sflag" != "yes" ]
  68.          then echo "directory    $a"
  69.          fi
  70.     elif [ -f $D1/"$a" ]
  71.     then cmp -s $D1/"$a" $D2/"$a"
  72.          if [ $? = 0 ]
  73.          then if [ "$Sflag" != "yes" ]
  74.           then echo "same         $a"
  75.           fi
  76.          else echo "different    $a"
  77.           if [ "$Dflag" = "yes" ]
  78.           then diff $D1/"$a" $D2/"$a" | pr -h "diff of $a in $D1 and $D2" >> /usr/tmp/dc$$g
  79.           fi
  80.          fi
  81.     elif [ "$Sflag" != "yes" ]
  82.     then echo "special      $a"
  83.     fi
  84. done < /usr/tmp/dc$$f | pr -r -h "Comparison of $D1 $D2"
  85. if [ "$Dflag" = "yes" ]
  86. then cat /usr/tmp/dc$$g
  87. fi
  88. rm -f /usr/tmp/dc$$*
  89.