Created
August 6, 2010 05:40
-
-
Save sarahhodne/510898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/sha1' | |
if ARGV.first.nil? || ['-h', '--help', '-?'].include?(ARGV.first) | |
puts "Usage: #{$0} <glob>" | |
exit 1 | |
end | |
files = Dir[ARGV.first].sort | |
files.each do |file| | |
next unless File.file? file | |
buf = "" | |
accum = "" | |
File.open(file, 'r:binary') do |f| | |
while (buf = f.read(510)) | |
accum << buf | |
f.seek(1024*1024*2, 1) | |
end | |
puts "#{file} #{Digest::SHA1.hexdigest(accum)}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you judofyr. I try to keep my GitHub stuff in English, so I'll do a short translation of the comment on the bottom: