Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

MD5 and SHA Hashes

by Green One (Initiate)
on Sep 02, 2014 at 23:08 UTC ( [id://1099324]=perlquestion: print w/replies, xml ) Need Help??

Green One has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to find a script that will parse through a group of flat file and pull out only the MD5 and/or SHA hashes and dump them one line at a time to another file. The end results can be over 16,000 lines.

Replies are listed 'Best First'.
Re: MD5 and SHA Hashes
by kennethk (Abbot) on Sep 02, 2014 at 23:42 UTC
    What have you tried? What worked? What didn't? Effort is appreciated. See How do I post a question effectively?.

    Using Digest::MD5 or Digest::SHA in a one-liner makes this fairly trivial:

    perl -MDigest::MD5=md5_hex -n0777e 'printf "%s\t%s\n", $ARGV, md5_hex +$_' * > file.log
    where you should probably swap the wildcard to the right one for your directory, and may choke on your file list depending on your shell.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      You don't even need Perl for this:

      $ md5sum * >md5sums.txt

      Substitute sha1sum (or any member of the sha*sum family) for md5sum as desired.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1099324]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found