- 论坛徽章:
- 0
|
不要以文件大小作为文件是否相同的参照, 用 md5sum的 值作为判断:
find 路径1 -name "*.*" > file1
find 路径2 -name "*.*" > file2
awk -f test.awk file1 file2
BEGIN{
FS = "/"
}
NR==FNR{
array1[$NF] = $0
}
NR!=FNR{
array2[$NF] = $0
}
END{
FS = " "
for (i in array1){
md5_1 = get_md5_value(array1[i])
if (! i in array2){
print "do not have the same fine name-------"
print array1[1]"\n"array2[2]
continue
}
md5_2 = get_md5_value(array2[i])
if (md5_1 != md5_2){
print "the file name is same, but the content is diff##############"
print array1[1]"\n"array2[2]
continue
}
}
print "ok, diff overr"
}
function get_md5_value(path){
"md5sum "path | getline
return $1
}
没有测试过 应该没多大的问题 |
|