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