diff options
-rwxr-xr-x | duplicates | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -3,23 +3,15 @@ dir = ARGV[0] a = `find #{dir} -type f`.split "\n" -md5cmd = "md5sum" -os = `uname`.strip -if os == "Darwin" - md5cmd = "md5" -end +hashcmd = "sha1sum" h = {} a.each { |fn| - if os == "Darwin" - md5 = `#{md5cmd} "#{fn}" | cut -d "=" -f2`.lstrip.strip + hash = `#{hashcmd} "#{fn}" | cut -d " " -f1`.strip + if h.has_key? hash + h[hash] << fn else - md5 = `#{md5cmd} "#{fn}" | cut -d " " -f1`.strip - end - if h.has_key? md5 - h[md5] << fn - else - h[md5] = [fn] + h[hash] = [fn] end } |