#! /bin/bash

# Lists all plain files unider ${dir} that are identical to the corresponding
# files in ${ref}

dir="$1"; shift
ref="$1"; shift

echo "finding files in ${dir} that are identical to those in ${ref}" 1>&2

# Get the names of files in "${dir}":
files=( `cd ${dir} && find ./ -type f -print | sed -e 's:^[.][/]::'` )

for f in "${files[@]}" ; do 
  dirfile="${dir}/$f"
  reffile="${ref}/$f"
  if cmp -s ${reffile} ${dirfile} ; then
    echo "identical: ${dirfile}"
  fi
done
