oscar@utcsrgv.UUCP (Oscar M. Nierstrasz) (12/18/83)
: Merge # This shell script merges directories, taking # care of common subdirectories. It will not # over-write files with the same names. # echo merge sed 's/^ //' > merge << 'Rosebud' : merge from to 831205 # Merges two directories, moving files and subdirectories # and removing empty directories. The two directories # should be disjoint, but merge will detect common files # and refuse to overwrite them. Merge logs its actions. # The results are unreliable if the second directory is a # subdirectory of the first. Merge must be run from # a parent of the first directory. # Author: Oscar Nierstrasz @ ..!utcsrgv!oscar if test $# -ne 2 then echo "Usage: merge <from dir> <to dir>" exit fi if test $1 = $2 then echo "merge: $1 and $2 are identical" exit fi if test -f $1 then echo "merge: $1 is not a directory; can't merge" exit fi if test ! -d $1 then echo "merge: $1 not found" exit fi if test -f $2 then echo "merge: $2 is not a directory; can't merge" exit fi if test ! -d $2 then echo "mv $1 $2" mv $1 $2 exit fi empty=`ls $1` if test -z "$empty" then echo "rmdir $1" rmdir $1 exit fi cd=`pwd` cd $1 files=`echo *` cd $cd for i in $files do if test -f $1/$i then if test -f $2/$i then echo "merge: $2/$i exists already -- $1/$i not moved" elif test -d $2/$i then echo "merge: $2/$i is a directory -- $1/$i not moved" else echo "mv $1/$i $2/$i" mv $1/$i $2/$i fi else merge $1/$i $2/$i fi done empty=`ls $1` if test -z "$empty" then echo "rmdir $1" rmdir $1 fi Rosebud -- # UUCP: { allegra cornell decvax decwrl floyd ihnp4 linus # sask ubc-vision utzoo uw-beaver watmath } !utcsrgv!oscar