Created
January 1, 2012 22:10
-
-
Save ahill00/1548482 to your computer and use it in GitHub Desktop.
Remove duplicates via checksum
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
#!/bin/bash | |
# rd - remove dupliactes | |
# http://nerdnotes.org/2008/12/remove-duplicate-files/ | |
# find the files using the specified 'find arguments' | |
find "$@" -type f -print0 | | |
# calculate checksum for each file | |
xargs -0 -n1 md5sum | | |
# sort on the checksum | |
sort --key=1,32 | | |
# show remove command for each duplicate file | |
awk 'dup[$1]++{print "rm -f " $2}' | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment