blob: c75194c4cb4d1d116ec3ad12d1a2d94356400c78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env ruby
dir = ARGV[0]
a = `find #{dir} -type f`.split "\n"
md5cmd = "md5sum"
os = `uname`.strip
if os == "Darwin"
md5cmd = "md5"
end
h = {}
a.each { |fn|
if os == "Darwin"
md5 = `#{md5cmd} "#{fn}" | cut -d "=" -f2`.lstrip.strip
else
md5 = `#{md5cmd} "#{fn}" | cut -d " " -f1`.strip
end
if h.has_key? md5
h[md5] << fn
else
h[md5] = [fn]
end
}
h.each { |k,v|
v.sort!
if v.size > 1
puts k
v.each { |i| puts "\t#{i}" }
puts
end
}
|