diff options
author | pks <pks@pks.rocks> | 2023-10-03 10:40:53 +0200 |
---|---|---|
committer | pks <pks@pks.rocks> | 2023-10-03 10:40:53 +0200 |
commit | 56cdc766cd4bb377f4e9ace610bc48834bf159ce (patch) | |
tree | 11974f70596ac77d4dd5fe9e643218604e8b9a30 | |
parent | 0b6cfee3dbed57638f5fa5f14ef2d730100873c8 (diff) |
duplicates: always use sha1sum
-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 } |