if [ $# -lt 2 ]; then
echo " Need Two Path"
exit
fi
src=(`ls $1 -Rl | grep ^[^d] | awk '{print $9}'`)
dest=(`ls $2 -Rl | grep ^[^d] | awk '{print $9}'`)
declare -i cnt
cnt=1
for( srcFile in ${src[*]}
do
for(destFile in ${dest[*]}
do
if[ $srcFile == $destFile ];then
echo $cnt; cnt=$cnt+1
echo $srcFile
cp `find $1 -name $srcFile` `find $2 -name $srcFile`
fi
done
done
原文:https://www.cnblogs.com/ims-/p/11067325.html