#! /bin/bash

# Writes to {stdout} all plain files unider ${dir} that are different from
# the corresponding files in ${ref}, or don't exist in ${ref}.

# Note: does NOT list files in ${ref} that don't exist in ${dir}.

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

echo "finding files in ${dir} that are distinct from 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
    continue
  else
    echo "${dirfile}"
  fi
done
