Advertisement
quark_zju

dupd

Dec 9th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.41 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'digest'
  4.  
  5. paths = ARGV.map{|v| Dir[v]}.flatten.uniq
  6.  
  7. def codehash(path)
  8.   Digest::MD5.hexdigest(File.read(path).gsub(/[\s;<>"]/,'').downcase)
  9. end
  10.  
  11. hashes = {}
  12.  
  13. # calc code hash
  14. paths.each do |path|
  15.  hash = codehash(path)
  16.  hashes[hash] ||= []
  17.  hashes[hash] << path
  18. end
  19.  
  20. # ouput duplicated
  21. hashes.select {|k,v| v.size > 1}.each do |k, v|
  22.  puts v.join("\t")
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement