#!/usr/local/bin/vcsh

if ( $#argv >= 1 ) then
	cd $1
	pwd
endif

set list = ( `find . -name "*.OLD" -print` )

foreach i ( $list )
	echo $i

	@ x = head{ $i , strlen{ $i } - 4 }
	echo $x
	if ( -r $x ) then
		cmp $x $i
		if ( $status == 0 ) then
			rm $i
			echo $i removed
		else
			ls -l $x $i
			echo ----------------- diff $x $i
			diff -b $x $i
			echo ----------------------------
		endif
	endif
end

set list = ( `find . -name "*.OLD.OLDER" -print` )

foreach i ( $list )
	echo $i

	@ x = head{ $i , strlen{ $i } - 10 }
	echo $x
	if ( -r $x ) then
		cmp $x $i
		if ( $status == 0 ) then
			rm $i
			echo $i removed
		else
			ls -l $x $i
			echo ----------------- diff $x $i
			diff -b $x $i
			echo ----------------------------
		endif
	endif
end

set list = ( `find . -name "*.OLDER" -print` )

foreach i ( $list )
	echo $i

	@ x = head{ $i , strlen{ $i } - 6 }
	echo $x
	if ( -r $x ) then
		cmp $x $i
		if ( $status == 0 ) then
			rm $i
			echo $i removed
		else
			ls -l $x $i
			echo ----------------- diff $x $i
			diff -b $x $i
			echo ----------------------------
		endif
	endif
end

echo ZERO SIZED FILES
find . -size 0c -ls

echo .DIR
find . -name "*.DIR" -print

echo .REDIR
find . -name "*.REDIRECT" -print
