Similar to edgarvm's but coping with new files as well as different ones...
Code:
new=/dist
old=/dist_old
diff=/dist_upgrade
cd $new
for f in *f
do
# Diff the files - ignore the output...
diff $f $old > /dev/null 2>&1
# ...but get the status
status=$?
if [ $status -eq 0 ] ; then
# Files are identical - don't copy the file
echo $f unchanged
elif [ $status -eq 1 ] ; then
# Files differ - copy new file
echo $f changed
cp $f $diff
elif [ $status -eq 2 ] ; then
# Old file doesn't exist - copy new file
echo old $f does not exist
cp $f $diff
fi
done