H='
==========
dcmp [-options] -d1 name -d2 name
==========
compare the files in directory_1 with those in directory_2.
==========
OPTIONS
==========
-l		link identical files
-r1		remove d1 copy of identical files
-r2 	remove d2 copy of identical files
==========
BUGS:
==========
does not check for files that are already linked.
==========
does not check for files that are in one directory but
not the other.
==========
'
FUBAR=69
CD=`pwd`
D1="."
D2="."
F1=/usr/tmp/da$$.tmp
F2=/usr/tmp/db$$.tmp
MO=L
while	:
do
case $1 in
	-x)				set -x;;
    -h|help|hint)  	clear;echo "$H";exit 0;;
	-d1)			shift;D1=$1;;
	-d2)			shift;D2=$1;;
	-l)				MO=L;;
	-r1)			MO=1;;
	-r2)			MO=2;;
	*)				clear;echo "$H";exit 69;;
esac
case $# in
	0|1)		break;;
	*)			shift;;
esac
done
:
find $D1 -type f -print > $F1
find $D2 -type f -print >> $F1
:
S='
s/\(.*\)\(\/\)\(.*\)/\3 \1\2\3/
'
A='
s/\(.*\)\(\/\)\(.*\)/\3/
'
sed -e "$S" $F1 | sort +0 -1 | sed -e "$A" | uniq -du > $F2
:
for i in `cat $F2`
do
A=$D1/$i
B=$D2/$i
if test ! -r $A
then
echo "! $A"
continue
fi
if test ! -r $B
then
echo "! $B"
continue
fi
cmp -s $A $B
S=$?
case $S in
	0)	DO="${MO}S";;
	1)	DO="${MO}D";;
esac
case $DO in
	LS)	rm -f $B;ln $A $B;;
	1S)	rm -f $A;;
	2S)	rm -f $B;;
	1D)	;;
	2D)	;;
	LD)	;;
	*)	echo "$DO <error>";exit 69;;
esac
echo "$DO $i"
done
