The closest you can get is to nest the for loops, i.e.
for f in $FILES1 ; do
for f2 in $FILES2 ; do
if [ ${f##*/} = ${f2##*/} ]; then
diff $f $f2
break
fi
done
done
to iterate thru recursive dirs, you could rely on find to return a list of files for processing
PATH1=/path/to/one
PATH2=/path/to/two
for f in $(find $PATH1 -print ) ; do
for f2 in $(find $PATH2 -print ) ; do
if [ ${f##*/} = ${f2##*/} ]; then
diff $f $f2
break
fi
done
done
Sorry I don't have a way to test this right now, the ${f##*/} may not be exactly right. The intention is to create just the basename of a file (I guess you could use that too, $(basename $f ) at the expense of an 2 processes for each.
Both of these are very expensive processes, checking lots of non-matching filename pairs. The break inside loop2 helps a little.
An alternate solution is to rely on one path to create the driver list and then use the supplied names to generate alternate relative paths, i.e.
for f in $FILES1 ; do
f2=../two/$f{##*/}
if [ -f ${f2} ] ; the
diff $f $f2
else
printf "no alternate file found in ../two for f=${f}"
fi
done
If need be, you can duplicate that loop and reverse the location of f2 and f to check the 'other-side' of your system.
I hope this helps.
diff -Naur /path/to/one /path/to/two?