Skip to content

Instantly share code, notes, and snippets.

@jsarenik
Created April 6, 2014 10:51
Show Gist options
  • Save jsarenik/10004429 to your computer and use it in GitHub Desktop.
Save jsarenik/10004429 to your computer and use it in GitHub Desktop.
#!/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