我想比较不同目录中同名的 2 个文件。$1 和 $2 是 2 个目录。我可以检查是否有同名文件,但是我不知道如何获取第二个文件..
cd $1
for i in `ls`
do
if [ -f $2/$i ]
then
echo "find it in another directory"
GET THE OTHER FILE IN $2, THEN COMPARE THEM
cmp -s $i THE OTHER FILE
if [ $? = 0 ]
echo "they are same"
else
echo "they are different"
fi
fi
done