Forked from OndraZizka/find-duplicate-files.bash
Last active
February 8, 2019 20:39
-
-
Save bodsch/ad22ea27b65685e9c1109f0e63ee3f2d to your computer and use it in GitHub Desktop.
Finds duplicate files. An alternative to `fdupes -r -S .`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find -type f -size +3M -print0 | while IFS= read -r -d '' i; do | |
#echo $i | |
echo -n '.' | |
if grep -q "$i" md5-partial.txt; then | |
echo -n ':'; #-e "\n$i ---- Already counted, skipping."; | |
continue; | |
fi | |
#md5sum "$i" >> md5.txt | |
MD5=`dd bs=1M count=1 if="$i" status=none | md5sum` | |
MD5=`echo $MD5 | cut -d' ' -f1` | |
if grep "$MD5" md5-partial.txt; then echo -e "Duplicate: $i"; fi | |
echo $MD5 $i >> md5-partial.txt | |
done | |
## Show the duplicates | |
#sort md5-partial.txt | uniq --check-chars=32 -d -c | |
#sort md5-partial.txt | uniq --check-chars=32 -d -c | sort -b -n | |
#sort md5-partial.txt | uniq --check-chars=32 -d -c | sort -b -n | cut -c 9-40 | xargs -I '{}' sh -c "grep '{}' md5-partial.txt && echo" | |
## Show wasted space | |
if [ false ] ; then | |
sort md5-partial.txt | uniq --check-chars=32 -d -c | while IFS= read -r -d '' LINE; do | |
HASH=`echo $LINE | cut -c 9-40`; | |
PATH=`echo $LINE | cut -c 41-`; | |
ls -l '$PATH' | cud -c 26-34 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment