有时候会好多,知道有的,但不知道是那些。下面的
可以找出当前目录或指定目录下所有大小相等的文件,然后配合后面两个脚本比较二进制文件。#!/bin/bash
#email:jyhln@163.com
#msn:jyhln@msn.com
#oicq:28995895
echo -n>/tmp/result_001.tmp
echo -n>/tmp/result.tmp
if [ $# -eq 0 ];then
dir_t=`pwd`
else
dir_t=`pwd $@`
fi
ls -Rlp -o --full-time $dir_t>/tmp/filelist_001.tmp
#create tmp file
flag=100
for line in `cat /tmp/filelist_001.tmp`;do
#path
if [ "`echo $line|grep ^/|grep :$`" ];then
flag=100
dir_swap=$line
continue
fi
#size
if [ "`echo $line|grep ^[-s][r-][-w][-x][-r]`" -a $flag -gt 10 ];then
flag=2
fi
flag=` expr $flag + 1 `
if [ $flag -eq 6 ];then
size=$line
continue
fi
#file
if [ $flag -eq 10 ];then
flag=100
echo -e $"$size \t$dir_swap\b/$line">>/tmp/result_001.tmp
#echo -e $"$size \t$dir_swap $line"
fi
done
#if have the same size
for byte in `cut /tmp/result_001.tmp -f 1`
do
counter=`grep -w ^"$byte" /tmp/result_001.tmp|wc -l`
if [ $counter -gt 1 ];then
test_n=`grep ^"$byte " /tmp/result.tmp`
if [ ! "$test_n" ];then
grep ^"$byte " /tmp/result_001.tmp>>/tmp/result.tmp
echo>>/tmp/result.tmp
fi
fi
done
cat /tmp/result.tmp
rm -f /tmp/result.tmp /tmp/filelist_001.tmp /tmp/result_001.tmp