比较不同目录下文件是否相同的脚本
时间:2007-11-20 来源:海天
#!/bin/bash
path1="/home/test1"
path2="/home/test2"
for file in $(find $path1 -type f -name '[^\.]*')
do
file=${file##*/}
for file1 in $(find $path2 -type f -name '[^\.]*')
do
file1=${file1##*/}
echo "-------------------------"
n=0
if [ "$file" == "$file1" ]
then
echo "$path1/$file is identical with $path2/$file1"
let 'n+=1'
echo "Total $n files are identical"
fi
done
done
path1="/home/test1"
path2="/home/test2"
for file in $(find $path1 -type f -name '[^\.]*')
do
file=${file##*/}
for file1 in $(find $path2 -type f -name '[^\.]*')
do
file1=${file1##*/}
echo "-------------------------"
n=0
if [ "$file" == "$file1" ]
then
echo "$path1/$file is identical with $path2/$file1"
let 'n+=1'
echo "Total $n files are identical"
fi
done
done
相关阅读 更多 +