Skip to content

Instantly share code, notes, and snippets.

@jsarenik jsarenik/dupfind.sh
Created Apr 6, 2014

Embed
What would you like to do?
#!/bin/sh -e
# SUM is any command that produces following output:
# <sum> <file>
#SUM="md5 -r"
SUM="md5sum"
# F is output file for the list of files found by sumfiles
F=/tmp/dupfind.tmp
FINDPTH="."
#FINDPMS="-name '*.tar*' -type f"
FINDPMS="-type f"
sumfiles() {
find $FINDPTH $FINDPMS -exec $SUM {} \;
}
listdupes() {
cut -d" " -f1 | sort | uniq -d
}
printmatches() {
while read sum
do
grep $sum $F
echo
done
}
sumfiles > $F
{ listdupes < $F; } | printmatches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.