Forked from OndraZizka/find-duplicate-files.bash
Last active
December 29, 2018 03:43
-
-
Save TomFaulkner/4e8a541e36c6214b6cd73738fa05192c to your computer and use it in GitHub Desktop.
Finds duplicate files. An alternative to `fdupes -r -S .`
This file contains hidden or 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 | |
fi | |
## 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' | cut -c 26-34 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment