by ColinWright · 5y ago · 0 comments
find * -type f -exec md5sum '{}' ';' \
| tee /tmp/index_file.txt \
| gawk '{print $1}' \
| sort | uniq -c \
| gawk '/^ *1 /{ print $2 } \
> /tmp/duplicates.txt
for m in $( cat /tmp/duplicates.txt )
do
grep $m /tmp/index_file.txt
echo ========
done \
| less
Tweak as necessary. I do have a comparison executable that only compares sizes and sub-portions to save time, but I generally find it's not worth it.It takes less time to type this that than it does to remember what some random other tool is called, or how to use it. I also have saved a variant that identifies similar files, and another that identifies directory structures with lots of shared files, but those are (understandably) more complex (and fragile).
Anyway, thanks for sharing - it is always very exciting to see how far you can go with a few unix utilities and a bit of scripting :)
find ... \! -empty ...
they have the same hash, but they do not need to be treated as duplicate
I'll check on it/them.