User Tools

Site Tools


wiki:check_the_same_file
one directory
#!/bin/sh
 
md5sum * > /tmp/md5.txt
sort /tmp/md5.txt > /tmp/mdd5.txt
rm -f /tmp/md5.txt
 
pmd=
pfn=
cat /tmp/mdd5.txt | while read md fn; do
        if [ "$md" = "" ]; then
                break;
        fi
        if [ "$pmd" != "" ]; then
                if [ "$pmd" = "$md" ]; then
                        rm -f "$fn"
                fi
        fi
        pmd=$md
        pfn=$fn
done
|different directory
#!/bin/sh
 
for f in *; do
        if [ -f "$1/$f" ]; then
                a=`md5sum "$f" | awk '{print $1}'`
                b=`md5sum "$1/$f" | awk '{print $1}'`
                if [ "$a" == "$b" ]; then
                        echo "del   $1/$f"
                        rm -f "$1/$f"
                fi
 
        fi
done
wiki/check_the_same_file.txt · Last modified: 2007/11/25 03:39 by mirnshi