diff --git a/dedupe b/dedupe new file mode 100755 index 0000000..4ecafa0 --- /dev/null +++ b/dedupe @@ -0,0 +1,16 @@ +#!/bin/sh +depth="-maxdepth 1" +case "$1" in + -r|--recursive) depth="" ;; + -h|--help) + echo "Usage: $(basename "$0") [-r]" + echo " -r, --recursive search subdirectories too" + exit 0 + ;; +esac + +find . $depth -type f -exec md5sum {} + | sort | awk '{ + if ($1 == prev) print "rm " $2 + prev = $1 +}' +