Skip to content

Instantly share code, notes, and snippets.

@ahill00
Created January 1, 2012 22:10
Show Gist options
  • Save ahill00/1548482 to your computer and use it in GitHub Desktop.
Save ahill00/1548482 to your computer and use it in GitHub Desktop.
Remove duplicates via checksum
#!/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