From 56cdc766cd4bb377f4e9ace610bc48834bf159ce Mon Sep 17 00:00:00 2001 From: pks Date: Tue, 3 Oct 2023 10:40:53 +0200 Subject: duplicates: always use sha1sum --- duplicates | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/duplicates b/duplicates index c75194c..5a92348 100755 --- a/duplicates +++ b/duplicates @@ -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 } -- cgit v1.2.3