Skip to content

Instantly share code, notes, and snippets.

@sarahhodne
Created August 6, 2010 05:40
Show Gist options
  • Save sarahhodne/510898 to your computer and use it in GitHub Desktop.
Save sarahhodne/510898 to your computer and use it in GitHub Desktop.
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
@sarahhodne
Copy link
Author

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:

Doesn't support globs, but your shell does that anyway. Same output as shasum (included in OSX)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment